mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
17 lines
489 B
TypeScript
17 lines
489 B
TypeScript
/**
|
|
* 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.
|
|
*/
|
|
|
|
export default () => (next: (arg0: any) => any) => (action: {effect: () => void}) => {
|
|
const ret = next(action);
|
|
if (action.effect) {
|
|
action.effect();
|
|
delete action.effect;
|
|
}
|
|
return ret;
|
|
};
|