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
23 lines (21 loc) • 715 B
JavaScript
import _default2 from 'ramda/src/is';
import _default from 'ramda/src/curry';
import { isAction } from '../util/is';
export default _default(function (logger, dispatch, enhancers, action) {
var enhance = enhancers[action.type];
if (_default2(Function, enhance)) {
try {
var nextAction = enhance(action);
if (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;
});