/
githubmirror
/
hyper
Обзор
Документация
Войти
/
githubmirror
/
hyper
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
canary
lib/utils/effects.ts
22 строки
792 B
Labhansh Agrawal
sort imports
25 июл 2023, 21:46
25 июл 2023, 21:46
36ff6e9
Код
Авторство
О чём код?
import type {Dispatch, Middleware} from 'redux'; import type {HyperActions, HyperState} from '../../typings/hyper'; /** * 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. */ const effectsMiddleware: Middleware<{}, HyperState, Dispatch<HyperActions>> = () => (next) => (action) => { const ret = next(action); if (action.effect) { // eslint-disable-next-line @typescript-eslint/no-unsafe-call action.effect(); delete action.effect; } // eslint-disable-next-line @typescript-eslint/no-unsafe-return return ret; }; export default effectsMiddleware;