Skip to content

Commit 617fa35

Browse files
[FSSDK-11098] using readyPromise instead of onReady (#995)
1 parent 8f572ff commit 617fa35

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/index.browser.tests.js

+4
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,10 @@ describe('javascript-sdk (Browser)', function() {
584584
const fakeOptimizely = {
585585
onReady: () => Promise.resolve({ success: true }),
586586
identifyUser: sinon.stub().returns(),
587+
isOdpIntegrated: () => true,
588+
readyPromise: Promise.resolve({
589+
success: true,
590+
}),
587591
};
588592

589593
const fakeErrorHandler = { handleError: function() {} };

lib/optimizely_user_context/index.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ export default class OptimizelyUserContext implements IOptimizelyUserContext {
6464
this.forcedDecisionsMap = {};
6565

6666
if (shouldIdentifyUser) {
67-
this.optimizely.onReady().then(({ success }) => {
68-
if (success) {
67+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
68+
// @ts-ignore
69+
optimizely.readyPromise.then(({ success }) => {
70+
if (success && optimizely.isOdpIntegrated()) {
6971
this.identifyUser();
7072
}
7173
});

0 commit comments

Comments
 (0)