Skip to content

Commit 13eaec3

Browse files
feat: update whenReadyFromCache to return boolean indicating SDK ready state
1 parent 1299349 commit 13eaec3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/readiness/sdkReadinessManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ export function sdkReadinessManagerFactory(
120120
},
121121

122122
whenReadyFromCache() {
123-
return new Promise<void>((resolve, reject) => {
123+
return new Promise<boolean>((resolve, reject) => {
124124
if (readinessManager.isReadyFromCache()) {
125-
resolve();
125+
resolve(readinessManager.isReady());
126126
} else if (readinessManager.hasTimedout()) {
127127
reject(TIMEOUT_ERROR);
128128
} else {
129-
readinessManager.gate.once(SDK_READY_FROM_CACHE, resolve);
129+
readinessManager.gate.once(SDK_READY_FROM_CACHE, () => resolve(readinessManager.isReady()));
130130
readinessManager.gate.once(SDK_READY_TIMED_OUT, () => reject(TIMEOUT_ERROR));
131131
}
132132
});

types/splitio.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,9 +781,9 @@ declare namespace SplitIO {
781781
* 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).
782782
* 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.
783783
*
784-
* @returns A promise that resolves once the SDK is ready from cache or rejects if the SDK has timedout.
784+
* @returns A promise that resolves once the SDK is ready from cache or rejects if the SDK has timedout. The promise resolves with a boolean value that indicates whether the SDK is ready (synchronized with the backend) or not.
785785
*/
786-
whenReadyFromCache(): Promise<void>;
786+
whenReadyFromCache(): Promise<boolean>;
787787
}
788788
/**
789789
* Common definitions between clients for different environments interface.

0 commit comments

Comments
 (0)