File tree 2 files changed +9
-0
lines changed
libs/providers/go-feature-flag-web/src/lib
2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ export class GoFeatureFlagWebProvider implements Provider {
38
38
private readonly _apiTimeout : number ;
39
39
// apiKey is the key used to identify your request in GO Feature Flag
40
40
private readonly _apiKey : string | undefined ;
41
+ // listener is an optional callback triggered after successful feature flag evaluation
42
+ private readonly _listener : ( ( key : string , value : FlagValue ) => void ) | undefined ;
41
43
42
44
// initial delay in millisecond to wait before retrying to connect
43
45
private readonly _retryInitialDelay ;
@@ -60,6 +62,7 @@ export class GoFeatureFlagWebProvider implements Provider {
60
62
this . _retryDelayMultiplier = options . retryDelayMultiplier || 2 ;
61
63
this . _maxRetries = options . maxRetries || 10 ;
62
64
this . _apiKey = options . apiKey ;
65
+ this . _listener = options . listener ;
63
66
}
64
67
65
68
get status ( ) : ProviderStatus {
@@ -223,6 +226,9 @@ export class GoFeatureFlagWebProvider implements Provider {
223
226
if ( typeof resolved . value !== type ) {
224
227
throw new TypeMismatchError ( `flag key ${ flagKey } is not of type ${ type } ` ) ;
225
228
}
229
+
230
+ this . _listener ?.( flagKey , resolved . value ) ;
231
+
226
232
return {
227
233
variant : resolved . variant ,
228
234
value : resolved . value as T ,
Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ export interface GoFeatureFlagWebProviderOptions {
50
50
// maximum number of retries before considering GO Feature Flag is unreachable
51
51
// Default: 10
52
52
maxRetries ?: number ;
53
+
54
+ // optional callback to trigger after successful feature flag evaluation
55
+ listener ?: ( key : string , value : FlagValue ) => void ;
53
56
}
54
57
55
58
/**
You can’t perform that action at this time.
0 commit comments