UNPKG

attadux

Version:

Implementation of the redux-modular-ducks, forked from the extensible-duck implementation and extended to include spected validators, state machines, helpers, web workers, effect handling, action multipliers, action enhancers, action throttling/debouncing

30 lines (28 loc) 1.17 kB
import _default3 from 'ramda/src/unnest'; import _default2 from 'ramda/src/is'; import _default from 'ramda/src/curry'; import { isAction } from '../util/is'; export default _default(function (logger, multipliers, dispatch, action) { multipliers.filter(function (multiplierMap) { return multiplierMap[action.type]; }).forEach(function (multiplierMap) { try { var fanout = multiplierMap[action.type]; var nextActions = fanout(action); if (_default2(Array, nextActions)) { _default3(nextActions).filter(function (na) { return isAction(na) && na.type !== action.type; }).forEach(function (nextAction) { try { dispatch(nextAction); } catch (err) { logger.error('Unable to dispatch action: "' + nextAction.type + '", multiplied from "' + action.type + '"', err); } }); } } catch (error) { logger.error('Unable to multiply action: "' + action.type + '"', error); } }); return action; });