@@ -21,6 +21,8 @@ class FeatureProbe extends TinyEmitter {
2121 private user : FPUser ;
2222 private toggles : { [ key : string ] : FPToggleDetail } | null ;
2323 private timer ?: NodeJS . Timeout ;
24+ private readyPromise : Promise < void > ;
25+
2426
2527 constructor ( ) {
2628 super ( ) ;
@@ -31,6 +33,13 @@ class FeatureProbe extends TinyEmitter {
3133 this . clientSdkKey = '' ;
3234 this . refreshInterval = 0 ;
3335 this . toggles = { } ;
36+ this . readyPromise = new Promise ( ( resolve ) => {
37+ const onReadyCallback = ( ) => {
38+ this . off ( EVENTS . READY , onReadyCallback ) ;
39+ resolve ( ) ;
40+ } ;
41+ this . on ( EVENTS . READY , onReadyCallback ) ;
42+ } ) ;
3443 }
3544
3645 public init ( {
@@ -79,6 +88,10 @@ class FeatureProbe extends TinyEmitter {
7988 clearInterval ( this . timer ) ;
8089 }
8190
91+ public waitUntilReady ( ) : Promise < void > {
92+ return this . readyPromise ;
93+ }
94+
8295 public boolValue ( key : string , defaultValue : boolean ) : boolean {
8396 return this . toggleValue ( key , defaultValue , "boolean" ) ;
8497 }
@@ -123,6 +136,11 @@ class FeatureProbe extends TinyEmitter {
123136 this . user = Object . assign ( { } , user ) ;
124137 }
125138
139+ public logout ( ) {
140+ const user = new FPUser ( ) ;
141+ this . identifyUser ( user ) ;
142+ }
143+
126144 static newForTest ( toggles : { [ key : string ] : any } ) : FeatureProbe {
127145 const fp = new FeatureProbe ( ) ;
128146 fp . init ( {
0 commit comments