@@ -53,9 +53,13 @@ export function readinessManagerFactory(
5353 lastUpdate = dateNow > lastUpdate ? dateNow : lastUpdate + 1 ;
5454 }
5555
56+ let metadataReady : SdkReadyMetadata = {
57+ initialCacheLoad : true , // true if not ready from cache (initial load), false if ready from cache
58+ lastUpdateTimestamp : undefined
59+ } ;
60+
5661 // emit SDK_READY_FROM_CACHE
5762 let isReadyFromCache = false ;
58- let cacheLastUpdateTimestamp : number | undefined = undefined ;
5963 if ( splits . splitsCacheLoaded ) isReadyFromCache = true ; // ready from cache, but doesn't emit SDK_READY_FROM_CACHE
6064 else splits . once ( SDK_SPLITS_CACHE_LOADED , checkIsReadyFromCache ) ;
6165
@@ -86,7 +90,7 @@ export function readinessManagerFactory(
8690 if ( splits . hasInit ) __init ( ) ;
8791
8892 function checkIsReadyFromCache ( cacheMetadata : SdkReadyMetadata ) {
89- cacheLastUpdateTimestamp = cacheMetadata . lastUpdateTimestamp ;
93+ metadataReady = cacheMetadata ;
9094 isReadyFromCache = true ;
9195 // Don't emit SDK_READY_FROM_CACHE if SDK_READY has been emitted
9296 if ( ! isReady && ! isDestroyed ) {
@@ -116,7 +120,6 @@ export function readinessManagerFactory(
116120 isReady = true ;
117121 try {
118122 syncLastUpdate ( ) ;
119- const wasReadyFromCache = isReadyFromCache ;
120123 if ( ! isReadyFromCache ) {
121124 isReadyFromCache = true ;
122125 const metadataReadyFromCache : SplitIO . SdkReadyMetadata = {
@@ -125,10 +128,6 @@ export function readinessManagerFactory(
125128 } ;
126129 gate . emit ( SDK_READY_FROM_CACHE , metadataReadyFromCache ) ;
127130 }
128- const metadataReady : SplitIO . SdkReadyMetadata = {
129- initialCacheLoad : ! wasReadyFromCache , // true if not ready from cache (initial load), false if ready from cache
130- lastUpdateTimestamp : wasReadyFromCache ? cacheLastUpdateTimestamp : undefined
131- } ;
132131 gate . emit ( SDK_READY , metadataReady ) ;
133132 } catch ( e ) {
134133 // throws user callback exceptions in next tick
0 commit comments