1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/src/lib/event-hook.ts
2023-03-02 09:52:19 +01:00

27 lines
703 B
TypeScript

import EventEmitter from 'events';
import { EventHook } from './types/option';
import {
FEATURE_CREATED,
FEATURE_UPDATED,
FEATURE_ARCHIVED,
FEATURE_REVIVED,
} from './types/events';
export const addEventHook = (
eventHook: EventHook,
eventStore: Pick<EventEmitter, 'on'>,
): void => {
eventStore.on(FEATURE_CREATED, (data) => {
eventHook(FEATURE_CREATED, data);
});
eventStore.on(FEATURE_UPDATED, (data) => {
eventHook(FEATURE_UPDATED, data);
});
eventStore.on(FEATURE_ARCHIVED, (data) => {
eventHook(FEATURE_ARCHIVED, data);
});
eventStore.on(FEATURE_REVIVED, (data) => {
eventHook(FEATURE_REVIVED, data);
});
};