anew
Version:
React and Redux Framework with additional power.
29 lines (24 loc) • 762 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = createBatchMiddleware;
function createBatchMiddleware(getBatches) {
return function batchMiddleware(_ref) {
var dispatch = _ref.dispatch;
return function (next) {
return function (action) {
var batches = getBatches();
var len = batches.length;
if (action.type !== '@@anew:BATCH' && !!len) {
dispatch({
type: '@@anew:BATCH',
payload: batches.splice(0, len)
});
return next(action);
}
return next(action);
};
};
};
}