UNPKG

ruddy

Version:

Modularized state-management tools for modern front-end applications. Manage dispatched messages in a clean and predictable way for either small or large scale projects

30 lines (28 loc) 1.02 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; });