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
Christopher Kolstad ff7be7696c
fix: Stores as typescript and with interfaces. (#902)
Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
2021-08-12 15:04:37 +02:00

27 lines
691 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: 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);
});
};