redux-batch-middleware
Version:
22 lines (18 loc) • 628 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var type = exports.type = '@@redux-batch-middleware/BATCH';
var batch = exports.batch = function batch(_ref) {
var dispatch = _ref.dispatch;
return function (next) {
return function (action) {
Array.isArray(action) ? dispatch({ type: type, payload: action }) : next(action);
};
};
};
var batching = exports.batching = function batching(reducer) {
return function batcher(state, action) {
return action.type === type ? action.payload.reduce(batcher, state) : reducer(state, action);
};
};