-
Notifications
You must be signed in to change notification settings - Fork 31
feat: implement waitForInitialization for browser sdk 4.x
#1028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@launchdarkly/browser size report |
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/js-client-sdk-common size report |
d324724 to
acf1ac7
Compare
unit tests broke because we introduced retries on initial polls which timed out of initial wait tests (since those tests were using fake timers). This change would simply advance the fake timer so all retries would have been triggered.
This commit will also fix this issue
Requirements
Related issues
waitForInitializeto browser 4.xDescribe the solution you've provided
Added
waitForInitializationfunction to browser 4.x implementation.Additional context
f({timeout: 5})instead off(5)rejectconditions... I can add those back in case we get an error status returned? At that point we might want to just wait for the timeout to throw.initializedevent that a successful identify will emit, I figured that would be a way for developers to know if LDClient initialized even if the initialization goes past timeout.Note
Adds
waitForInitialization({ timeout })to the browser SDK, resolves on identify success/failure or timeout, and emits aninitializedevent; includes comprehensive tests.LDClient.waitForInitialization(options?: { timeout: number })returningLDWaitForInitializationResult(complete|failed|timeout).BrowserClientImpl.completeon successfulidentify,failedonidentifyerror, ortimeoutviacancelableTimedPromise.waitForInitializationon returned client frommakeClient.LDWaitForInitializationOptions,LDWaitForInitializationComplete|Failed|Timeoutand unionLDWaitForInitializationResultinpackages/sdk/browser/src/LDClient.ts.initializedon successful identify in sharedLDClientImpl.EventNameto includeinitialized.compat/LDClientCompatomitswaitForInitializationfrom its interface to preserve 3.x surface.Written by Cursor Bugbot for commit 4c64b0d. This will update automatically on new commits. Configure here.