UNPKG

redux-sequence-action

Version:
16 lines (13 loc) 425 B
export default ({dispatch, getState}) => next => action => { if(!Array.isArray(action)) { return next(action); } return action.reduce( (result, currAction) => { return result.then(() => { if (!currAction) { return Promise.resolve(); } return Array.isArray(currAction) ? Promise.all(currAction.map(item => dispatch(item))) : dispatch(currAction); }); }, Promise.resolve()); }