diff --git a/packages/client/test/events.spec.ts b/packages/client/test/events.spec.ts index f417fb626..5272694f3 100644 --- a/packages/client/test/events.spec.ts +++ b/packages/client/test/events.spec.ts @@ -519,6 +519,16 @@ describe('Events', () => { // emit a change event from the mock provider provider.events?.emit(ProviderEvents.ConfigurationChanged, { flagsChanged: [changedFlag] }); }); + + it('It allows iteration over all event types', () => { + // just a typings test; it should be possible to iterate over a collection of ProviderEvents, + const client = OpenFeature.getClient(domain); + const providerEvents: ProviderEvents[] = []; + + providerEvents.forEach((e) => { + client.addHandler(e, () => {}); + }); + }); }); describe('Requirement 5.3.3', () => { diff --git a/packages/server/test/events.spec.ts b/packages/server/test/events.spec.ts index 4198d7da0..044689c66 100644 --- a/packages/server/test/events.spec.ts +++ b/packages/server/test/events.spec.ts @@ -499,6 +499,16 @@ describe('Events', () => { // emit a change event from the mock provider provider.events?.emit(ProviderEvents.ConfigurationChanged, { flagsChanged: [changedFlag] }); }); + + it('It allows iteration over all event types', () => { + // just a typings test; it should be possible to iterate over a collection of ProviderEvents, + const client = OpenFeature.getClient(domain); + const providerEvents: ProviderEvents[] = []; + + providerEvents.forEach((e) => { + client.addHandler(e, () => {}); + }); + }); }); describe('Requirement 5.3.3', () => { diff --git a/packages/shared/src/events/eventing.ts b/packages/shared/src/events/eventing.ts index fb4890274..753bfebb7 100644 --- a/packages/shared/src/events/eventing.ts +++ b/packages/shared/src/events/eventing.ts @@ -87,6 +87,10 @@ export interface Eventing eventType: T extends ClientProviderEvents ? ClientNotChangeEvents : ServerNotChangeEvents, handler: EventHandler, ): void; + addHandler( + eventType: T extends ClientProviderEvents ? ClientProviderEvents : ServerProviderEvents, + handler: EventHandler, + ): void; /** * Removes a handler for the given provider event type.