1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 1x 1x 1x 1x 2x 8x 2x | import invariant from 'invariant' export const BATCH = 'CORE/BATCH' export function batchReducer(reducer) { return function(state, action) { Eif (action.type === BATCH) { return action.payload.reduce(reducer, state) } return reducer(state, action) } } export function batch(actions) { invariant( Array.isArray(actions) && actions.every(a => typeof a === 'object'), 'batch() expects an array of basic Redux actions' ) return { type: BATCH, payload: actions } } |