1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/lib/event-hook.js
Ran Magen d917e8018f feat: add option and functionality that allows a user to hook into feature mutations (#457)
* Add option and functionality that allows a user to hook into feature mutations.

* Fix function argument to include the entire event.
2020-02-20 08:34:26 +01:00

24 lines
575 B
JavaScript

'use strict';
const {
FEATURE_CREATED,
FEATURE_UPDATED,
FEATURE_ARCHIVED,
FEATURE_REVIVED,
} = require('./event-type');
exports.addEventHook = (eventHook, eventStore) => {
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);
});
};