1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-31 00:16:47 +01:00
unleash.unleash/lib/event-hook.js
Ran Magen 530bfcec1b 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.
2019-06-18 19:22:18 +02: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);
});
};