hyper/lib/utils/effects.ts

18 lines
489 B
TypeScript
Raw Normal View History

/**
* Simple redux middleware that executes
* the `effect` field if provided in an action
* since this is preceded by the `plugins`
* middleware. It allows authors to interrupt,
* defer or add to existing side effects at will
* as the result of an action being triggered.
*/
2016-07-13 12:44:24 -08:00
2019-10-12 02:16:45 -08:00
export default () => (next: (arg0: any) => any) => (action: {effect: () => void}) => {
2016-07-13 12:44:24 -08:00
const ret = next(action);
if (action.effect) {
action.effect();
delete action.effect;
}
return ret;
};