@@ -267,43 +267,52 @@ This can be a new repository or included in [the existing contrib repository](ht
267267You’ll then need to write the provider by implementing the [ Provider interface] ( ./src/provider/provider.ts ) exported by the OpenFeature SDK.
268268
269269``` ts
270- import { JsonValue , Provider , ResolutionDetails } from ' @openfeature/web-sdk' ;
270+ import {
271+ AnyProviderEvent ,
272+ EvaluationContext ,
273+ Hook ,
274+ JsonValue ,
275+ Logger ,
276+ Provider ,
277+ ProviderEventEmitter ,
278+ ProviderStatus ,
279+ ResolutionDetails
280+ } from ' @openfeature/web-sdk' ;
271281
272282// implement the provider interface
273283class MyProvider implements Provider {
274284 // Adds runtime validation that the provider is used with the expected SDK
275- public readonly runsOn = ' client' ;
276-
285+ public readonly runsOn = ' server' ;
277286 readonly metadata = {
278287 name: ' My Provider' ,
279288 } as const ;
280-
281289 // Optional provider managed hooks
282- hooks? : Hook <FlagValue >[];
283-
290+ hooks? : Hook [];
284291 resolveBooleanEvaluation(flagKey : string , defaultValue : boolean , context : EvaluationContext , logger : Logger ): ResolutionDetails <boolean > {
285292 // code to evaluate a boolean
286293 }
287-
288294 resolveStringEvaluation(flagKey : string , defaultValue : string , context : EvaluationContext , logger : Logger ): ResolutionDetails <string > {
289295 // code to evaluate a string
290296 }
291-
292297 resolveNumberEvaluation(flagKey : string , defaultValue : number , context : EvaluationContext , logger : Logger ): ResolutionDetails <number > {
293298 // code to evaluate a number
294299 }
295-
296300 resolveObjectEvaluation<T extends JsonValue >(flagKey : string , defaultValue : T , context : EvaluationContext , logger : Logger ): ResolutionDetails <T > {
297301 // code to evaluate an object
298302 }
299303
304+ onContextChange? (oldContext : EvaluationContext , newContext : EvaluationContext ): Promise <void > {
305+ // reconcile the provider's cached flags, if applicable
306+ }
307+
300308 status? : ProviderStatus | undefined ;
301- events? : OpenFeatureEventEmitter | undefined ;
309+
310+ // implement with "new OpenFeatureEventEmitter()", and use "emit()" to emit events
311+ events? : ProviderEventEmitter <AnyProviderEvent > | undefined ;
302312
303313 initialize? (context ? : EvaluationContext | undefined ): Promise <void > {
304314 // code to initialize your provider
305315 }
306-
307316 onClose? (): Promise <void > {
308317 // code to shut down your provider
309318 }
0 commit comments