Skip to content

Commit

Permalink
fixup: pr comments
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Baert <[email protected]>
  • Loading branch information
toddbaert committed Jan 8, 2024
1 parent 79225c2 commit 97d32d5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
4 changes: 4 additions & 0 deletions packages/client/src/events/events.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ClientProviderEvents } from '@openfeature/core';

export { ClientProviderEvents as ProviderEvents};

/**
* A subset of events that can be directly emitted by providers.
*/
export type ProviderEmittableEvents = Exclude<ClientProviderEvents, ClientProviderEvents.ContextChanged>;
3 changes: 1 addition & 2 deletions packages/client/src/open-feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class OpenFeatureAPI extends OpenFeatureCommonAPI<Provider, Hook> impleme
newContext: EvaluationContext,
): Promise<void> {
const providerName = provider.metadata.name;
return await provider.onContextChange?.(oldContext, newContext).then(() => {
return provider.onContextChange?.(oldContext, newContext).then(() => {
this.getAssociatedEventEmitters(clientName).forEach((emitter) => {
emitter?.emit(ProviderEvents.ContextChanged, { clientName, providerName });
});
Expand All @@ -209,7 +209,6 @@ export class OpenFeatureAPI extends OpenFeatureCommonAPI<Provider, Hook> impleme
});
this._events?.emit(ProviderEvents.Error, { clientName, providerName, message: err?.message, });
});

}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/events/event-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const eventStatusMap = {
/**
* Returns true if the provider's status corresponds to the event.
* If the provider's status is not defined, it matches READY.
* @param {ProviderEvents} event event to match
* @param {AnyProviderEvent} event event to match
* @param {ProviderStatus} status status of provider
* @returns {boolean} boolean indicating if the provider status corresponds to the event.
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/shared/src/events/eventing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ export interface Eventing {
/**
* Adds a handler for the given provider event type.
* The handlers are called in the order they have been added.
* @param {ProviderEvents} eventType The provider event type to listen to
* @param {AnyProviderEvent} eventType The provider event type to listen to
* @param {EventHandler} handler The handler to run on occurrence of the event type
*/
addHandler(eventType: AnyProviderEvent, handler: EventHandler): void;

/**
* Removes a handler for the given provider event type.
* @param {ProviderEvents} eventType The provider event type to remove the listener for
* @param {AnyProviderEvent} eventType The provider event type to remove the listener for
* @param {EventHandler} handler The handler to remove for the provider event type
*/
removeHandler(eventType: AnyProviderEvent, handler: EventHandler): void;

/**
* Gets the current handlers for the given provider event type.
* @param {ProviderEvents} eventType The provider event type to get the current handlers for
* @param {AnyProviderEvent} eventType The provider event type to get the current handlers for
* @returns {EventHandler[]} The handlers currently attached to the given provider event type
*/
getHandlers(eventType: AnyProviderEvent): EventHandler[];
Expand Down
6 changes: 3 additions & 3 deletions packages/shared/src/open-feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export abstract class OpenFeatureCommonAPI<P extends CommonProvider = CommonProv
* Adds a handler for the given provider event type.
* The handlers are called in the order they have been added.
* API (global) events run for all providers.
* @param {ProviderEvents} eventType The provider event type to listen to
* @param {AnyProviderEvent} eventType The provider event type to listen to
* @param {EventHandler} handler The handler to run on occurrence of the event type
*/
addHandler<T extends AnyProviderEvent>(eventType: T, handler: EventHandler): void {
Expand All @@ -101,7 +101,7 @@ export abstract class OpenFeatureCommonAPI<P extends CommonProvider = CommonProv

/**
* Removes a handler for the given provider event type.
* @param {ProviderEvents} eventType The provider event type to remove the listener for
* @param {AnyProviderEvent} eventType The provider event type to remove the listener for
* @param {EventHandler} handler The handler to remove for the provider event type
*/
removeHandler<T extends AnyProviderEvent>(eventType: T, handler: EventHandler): void {
Expand All @@ -110,7 +110,7 @@ export abstract class OpenFeatureCommonAPI<P extends CommonProvider = CommonProv

/**
* Gets the current handlers for the given provider event type.
* @param {ProviderEvents} eventType The provider event type to get the current handlers for
* @param {AnyProviderEvent} eventType The provider event type to get the current handlers for
* @returns {EventHandler[]} The handlers currently attached to the given provider event type
*/
getHandlers<T extends AnyProviderEvent>(eventType: T): EventHandler[] {
Expand Down

0 comments on commit 97d32d5

Please sign in to comment.