Skip to content

Commit e49de68

Browse files
Revert "Add method to retrieve client readiness status synchronously"
This reverts commit 1eeff81.
1 parent e2179d7 commit e49de68

File tree

5 files changed

+20
-56
lines changed

5 files changed

+20
-56
lines changed

src/readiness/__tests__/sdkReadinessManager.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ describe('SDK Readiness Manager - Event emitter', () => {
5151
});
5252

5353
expect(typeof sdkStatus.ready).toBe('function'); // The sdkStatus exposes a .ready() function.
54-
expect(typeof sdkStatus.getStatus).toBe('function'); // The sdkStatus exposes a .getStatus() function.
55-
expect(sdkStatus.getStatus()).toEqual({
54+
expect(typeof sdkStatus.__getStatus).toBe('function'); // The sdkStatus exposes a .__getStatus() function.
55+
expect(sdkStatus.__getStatus()).toEqual({
5656
isReady: false, isReadyFromCache: false, isTimedout: false, hasTimedout: false, isDestroyed: false, isOperational: false, lastUpdate: 0
5757
});
5858

src/readiness/sdkReadinessManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export function sdkReadinessManagerFactory(
132132
});
133133
},
134134

135-
getStatus() {
135+
__getStatus() {
136136
return {
137137
isReady: readinessManager.isReady(),
138138
isReadyFromCache: readinessManager.isReadyFromCache(),

src/readiness/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { IStatusInterface } from '../types';
12
import SplitIO from '../../types/splitio';
23

34
/** Splits data emitter */
@@ -71,7 +72,7 @@ export interface IReadinessManager {
7172

7273
export interface ISdkReadinessManager {
7374
readinessManager: IReadinessManager
74-
sdkStatus: SplitIO.IStatusInterface
75+
sdkStatus: IStatusInterface
7576

7677
/**
7778
* Increment internalReadyCbCount, an offset value of SDK_READY listeners that are added/removed internally

src/types.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@ export interface ISettings extends SplitIO.ISettings {
1414
readonly initialRolloutPlan?: RolloutPlan;
1515
}
1616

17+
/**
18+
* SplitIO.IStatusInterface interface extended with private properties for internal use
19+
*/
20+
export interface IStatusInterface extends SplitIO.IStatusInterface {
21+
// Expose status for internal purposes only. Not considered part of the public API, and might be updated eventually.
22+
__getStatus(): {
23+
isReady: boolean;
24+
isReadyFromCache: boolean;
25+
isTimedout: boolean;
26+
hasTimedout: boolean;
27+
isDestroyed: boolean;
28+
isOperational: boolean;
29+
lastUpdate: number;
30+
};
31+
}
1732
/**
1833
* SplitIO.IBasicClient interface extended with private properties for internal use
1934
*/

types/splitio.d.ts

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -691,52 +691,6 @@ declare namespace SplitIO {
691691
[status in ConsentStatus]: ConsentStatus;
692692
};
693693
}
694-
/**
695-
* Readiness Status interface. It represents the readiness state of an SDK client.
696-
*/
697-
interface ReadinessStatus {
698-
699-
/**
700-
* `isReady` indicates if the client has triggered an `SDK_READY` event and
701-
* thus is ready to evaluate with cached data synchronized with the backend.
702-
*/
703-
isReady: boolean;
704-
705-
/**
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, not synchronized with the backend.
708-
*/
709-
isReadyFromCache: boolean;
710-
711-
/**
712-
* `isTimedout` indicates if the client has triggered an `SDK_READY_TIMED_OUT` event and is not ready to evaluate.
713-
* In other words, `isTimedout` is equivalent to `hasTimedout && !isReady`.
714-
*/
715-
isTimedout: boolean;
716-
717-
/**
718-
* `hasTimedout` indicates if the client has ever triggered an `SDK_READY_TIMED_OUT` event.
719-
* It's meant to keep a reference that the SDK emitted a timeout at some point, not the current state.
720-
*/
721-
hasTimedout: boolean;
722-
723-
/**
724-
* `isDestroyed` indicates if the client has been destroyed, i.e., `destroy` method has been called.
725-
*/
726-
isDestroyed: boolean;
727-
728-
/**
729-
* `isOperational` indicates if the client can evaluate feature flags.
730-
* In this state, `getTreatment` calls will not return `CONTROL` due to the SDK being unready or destroyed.
731-
* It's equivalent to `isReadyFromCache && !isDestroyed`.
732-
*/
733-
isOperational: boolean;
734-
735-
/**
736-
* `lastUpdate` indicates the timestamp of the most recent status event.
737-
*/
738-
lastUpdate: number;
739-
}
740694
/**
741695
* Common API for entities that expose status handlers.
742696
*/
@@ -745,12 +699,6 @@ declare namespace SplitIO {
745699
* Constant object containing the SDK events for you to use.
746700
*/
747701
Event: EventConsts;
748-
/**
749-
* Gets the readiness status.
750-
*
751-
* @returns The current readiness status.
752-
*/
753-
getStatus(): ReadinessStatus;
754702
/**
755703
* 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).
756704
* 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.

0 commit comments

Comments
 (0)