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
34 lines (26 loc) • 981 B
JavaScript
;
exports.__esModule = true;
var _is = require('ramda/src/is');
var _is2 = _interopRequireDefault(_is);
var _curry = require('ramda/src/curry');
var _curry2 = _interopRequireDefault(_curry);
var _is3 = require('../util/is');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
exports['default'] = (0, _curry2['default'])(function (logger, dispatch, enhancers, action) {
var enhance = enhancers[action.type];
if ((0, _is2['default'])(Function, enhance)) {
try {
var nextAction = enhance(action);
if ((0, _is3.isAction)(nextAction)) {
if (nextAction.type !== action.type) {
dispatch(nextAction);
} else {
return nextAction;
}
}
} catch (error) {
logger.error('Unable to enhance action: "' + action.type + '"', error);
}
}
return action;
});