You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constTIMEOUT_ERROR=newError('Split SDK has emitted SDK_READY_TIMED_OUT event.');
12
13
13
14
/**
14
15
* SdkReadinessManager factory, which provides the public status API of SDK clients and manager: ready promise, readiness event emitter and constants (SDK_READY, etc).
@@ -93,17 +94,44 @@ export function sdkReadinessManagerFactory(
93
94
SDK_READY_TIMED_OUT,
94
95
},
95
96
97
+
// @TODO: remove in next major
96
98
ready(){
97
99
if(readinessManager.hasTimedout()){
98
100
if(!readinessManager.isReady()){
99
-
returnpromiseWrapper(Promise.reject(newError('Split SDK has emitted SDK_READY_TIMED_OUT event.')),defaultOnRejected);
Copy file name to clipboardExpand all lines: types/splitio.d.ts
+23-8Lines changed: 23 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -525,19 +525,19 @@ declare namespace SplitIO {
525
525
*/
526
526
typeEventConsts={
527
527
/**
528
-
* The ready event.
528
+
* The ready event emitted once the SDK is ready to evaluate feature flags with cache synchronized with the backend.
529
529
*/
530
530
SDK_READY: 'init::ready';
531
531
/**
532
-
* The ready event when fired with cached data.
532
+
* The ready event emitted once the SDK is ready to evaluate feature flags with cache that could be stale. Use SDK_READY if you want to be sure the cache is in sync with the backend.
533
533
*/
534
534
SDK_READY_FROM_CACHE: 'init::cache-ready';
535
535
/**
536
-
* The timeout event.
536
+
* The timeout event emitted after `startup.readyTimeout` seconds if the SDK_READY event was not emitted.
537
537
*/
538
538
SDK_READY_TIMED_OUT: 'init::timeout';
539
539
/**
540
-
* The update event.
540
+
* The update event emitted when the SDK cache is updated with new data from the backend.
541
541
*/
542
542
SDK_UPDATE: 'state::update';
543
543
};
@@ -704,7 +704,7 @@ declare namespace SplitIO {
704
704
705
705
/**
706
706
* `isReadyFromCache` indicates if the client has triggered an `SDK_READY_FROM_CACHE` event and
707
-
* thus is ready to evaluate with cached data, although the data in cache might be stale.
707
+
* thus is ready to evaluate with cached data, although the data in cache might be stale, not synchronized with the backend.
708
708
*/
709
709
isReadyFromCache: boolean;
710
710
@@ -728,7 +728,7 @@ declare namespace SplitIO {
728
728
/**
729
729
* `isOperational` indicates if the client can evaluate feature flags.
730
730
* In this state, `getTreatment` calls will not return `CONTROL` due to the SDK being unready or destroyed.
731
-
* It's equivalent to `(isReady || isReadyFromCache) && !isDestroyed`.
731
+
* It's equivalent to `isReadyFromCache && !isDestroyed`.
732
732
*/
733
733
isOperational: boolean;
734
734
@@ -752,7 +752,7 @@ declare namespace SplitIO {
752
752
*/
753
753
getStatus(): ReadinessStatus;
754
754
/**
755
-
* Returns a promise that resolves once the SDK has finished loading (`SDK_READY` event emitted) or rejected if the SDK has timedout (`SDK_READY_TIMED_OUT` event emitted).
755
+
* Returns a promise that resolves once the SDK has finished synchronizing with the backend (`SDK_READY` event emitted) or rejected if the SDK has timedout (`SDK_READY_TIMED_OUT` event emitted).
756
756
* As it's meant to provide similar flexibility to the event approach, given that the SDK might be eventually ready after a timeout event, the `ready` method will return a resolved promise once the SDK is ready.
757
757
*
758
758
* Caveats: the method was designed to avoid an unhandled Promise rejection if the rejection case is not handled, so that `onRejected` handler is optional when using promises.
@@ -767,8 +767,23 @@ declare namespace SplitIO {
767
767
* ```
768
768
*
769
769
* @returns A promise that resolves once the SDK is ready or rejects if the SDK has timedout.
770
+
* @deprecated Use `whenReady` instead.
770
771
*/
771
772
ready(): Promise<void>;
773
+
/**
774
+
* Returns a promise that resolves once the SDK is ready for evaluations using cached data synchronized with the backend (`SDK_READY` event emitted) or rejected if the SDK has timedout (`SDK_READY_TIMED_OUT` event emitted).
775
+
* As it's meant to provide similar flexibility to the event approach, given that the SDK might be eventually ready after a timeout event, the `whenReady` method will return a resolved promise once the SDK is ready.
776
+
*
777
+
* @returns A promise that resolves once the SDK is ready or rejects if the SDK has timedout.
778
+
*/
779
+
whenReady(): Promise<void>;
780
+
/**
781
+
* Returns a promise that resolves once the SDK is ready for evaluations using cached data which might not yet be synchronized with the backend (`SDK_READY_FROM_CACHE` event emitted) or rejected if the SDK has timedout (`SDK_READY_TIMED_OUT` event emitted).
782
+
* As it's meant to provide similar flexibility to the event approach, given that the SDK might be eventually ready from cache after a timeout event, the `whenReadyFromCache` method will return a resolved promise once the SDK is ready from cache.
783
+
*
784
+
* @returns A promise that resolves once the SDK is ready from cache or rejects if the SDK has timedout.
785
+
*/
786
+
whenReadyFromCache(): Promise<void>;
772
787
}
773
788
/**
774
789
* Common definitions between clients for different environments interface.
@@ -1702,7 +1717,7 @@ declare namespace SplitIO {
1702
1717
* Wait for the SDK client to be ready before calling this method.
0 commit comments