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
22 lines (19 loc) • 629 B
JavaScript
import _default from 'ramda/src/curry';
import { isPromise, isAction } from '../util/is';
export var resultHandler = _default(function (dispatch, action, result) {
if (isAction(result) && action.type !== result.type) {
dispatch(result);
}
});
export default _default(function (logger, effects, dispatch, action) {
var handleResult = resultHandler(dispatch, action);
effects.forEach(function (effect) {
var result = effect(action);
if (isPromise(result)) {
result.then(handleResult);
} else {
handleResult(result);
}
});
return action;
});