Skip to content

Commit 1b1865a

Browse files
Update IStatusInterface
1 parent 7270dd0 commit 1b1865a

File tree

6 files changed

+22
-5
lines changed

6 files changed

+22
-5
lines changed

CHANGES.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
1.17.0 (September 6, 2024)
2-
- Added lastUpdate property to ReadinessManager to keep track of the timestamp of the last SDK event, used on React and Redux SDKs.
1+
1.17.0 (September XX, 2024)
2+
- Added `isTimedout` and `lastUpdate` properties to IStatusInterface to keep track of the timestamp of the last SDK event, used on React and Redux SDKs.
33
- Updated some transitive dependencies for vulnerability fixes.
44

55
1.16.0 (June 13, 2024)

src/readiness/__tests__/sdkReadinessManager.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ describe('SDK Readiness Manager - Event emitter', () => {
5050
});
5151

5252
expect(typeof sdkStatus.ready).toBe('function'); // The sdkStatus exposes a .ready() function.
53+
expect(typeof sdkStatus.__getStatus).toBe('function'); // The sdkStatus exposes a .__getStatus() function.
54+
expect(sdkStatus.__getStatus()).toEqual({
55+
isReady: false, isReadyFromCache: false, isTimeout: false, hasTimedout: false, isDestroyed: false, isOperational: false, lastUpdate: 0
56+
});
5357

5458
expect(typeof sdkStatus.Event).toBe('object'); // It also exposes the Event map,
5559
expect(sdkStatus.Event.SDK_READY).toBe(SDK_READY); // which contains the constants for the events, for backwards compatibility.

src/readiness/readinessManager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ export function readinessManagerFactory(
143143
},
144144

145145
isReady() { return isReady; },
146-
hasTimedout() { return hasTimedout; },
147146
isReadyFromCache() { return isReadyFromCache; },
147+
isTimedout() { return hasTimedout && !isReady; },
148+
hasTimedout() { return hasTimedout; },
148149
isDestroyed() { return isDestroyed; },
149150
isOperational() { return (isReady || isReadyFromCache) && !isDestroyed; },
150151
lastUpdate() { return lastUpdate; }

src/readiness/sdkReadinessManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ export function sdkReadinessManagerFactory(
121121
return readyPromise;
122122
},
123123

124-
// Expose status for internal purposes only. Not considered part of the public API, and might be updated eventually.
125124
__getStatus() {
126125
return {
127126
isReady: readinessManager.isReady(),
128127
isReadyFromCache: readinessManager.isReadyFromCache(),
129-
isOperational: readinessManager.isOperational(),
128+
isTimedout: readinessManager.isTimedout(),
130129
hasTimedout: readinessManager.hasTimedout(),
131130
isDestroyed: readinessManager.isDestroyed(),
131+
isOperational: readinessManager.isOperational(),
132132
lastUpdate: readinessManager.lastUpdate(),
133133
};
134134
},

src/readiness/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export interface IReadinessManager {
5050
/** Readiness status */
5151
isReady(): boolean,
5252
isReadyFromCache(): boolean,
53+
isTimedout(): boolean,
5354
hasTimedout(): boolean,
5455
isDestroyed(): boolean,
5556
isOperational(): boolean,

src/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,17 @@ export interface IStatusInterface extends IEventEmitter {
403403
* @returns {Promise<void>}
404404
*/
405405
ready(): Promise<void>
406+
407+
// Expose status for internal purposes only. Not considered part of the public API, and might be updated eventually.
408+
__getStatus(): {
409+
isReady: boolean;
410+
isReadyFromCache: boolean;
411+
isTimedout: boolean;
412+
hasTimedout: boolean;
413+
isDestroyed: boolean;
414+
isOperational: boolean;
415+
lastUpdate: number;
416+
}
406417
}
407418
/**
408419
* Common definitions between clients for different environments interface.

0 commit comments

Comments
 (0)