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

27 lines
691 B
TypeScript
Raw Normal View History

2021-05-21 16:51:13 +02:00
import EventEmitter from 'events';
2021-05-02 21:11:17 +02:00
import { EventHook } from './types/option';
import {
FEATURE_CREATED,
FEATURE_UPDATED,
FEATURE_ARCHIVED,
FEATURE_REVIVED,
2021-05-02 21:11:17 +02:00
} from './types/events';
2021-05-02 21:11:17 +02:00
export const addEventHook = (
eventHook: EventHook,
eventStore: EventEmitter,
): 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);
});
};