Skip to content

Instantly share code, notes, and snippets.

@lucaronca
Created March 1, 2019 16:00
Show Gist options
  • Save lucaronca/57ea17f61b7ebb3bac810dd47bd40d1d to your computer and use it in GitHub Desktop.
Save lucaronca/57ea17f61b7ebb3bac810dd47bd40d1d to your computer and use it in GitHub Desktop.
const pipeActions = reducer => (...actions) => {
const getStateAfterActions = (state, actionToExecute, ...actions) => {
return actionToExecute ?
getStateAfterActions(reducer(state, actionToExecute), ...actions) :
state;
};
return getStateAfterActions(undefined, ...actions);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment