Guest User

Untitled

a guest
Apr 25th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. /**
  2. * Supply multiple reducer functions, as arguments, and return a new reducer function that pipes the
  3. * state and action through each reducer in sequence.
  4. * @param {...functions} reducers like (arg1, arg2, ...), as a serires of arguments.
  5. * @return {function} a new reducer function that pipes the state and action through each reducer in sequence.
  6. * Each successive reducer will receive the updated returned by the previous reducer.
  7. */
  8. export default function reduceReducers(...reducers) {
  9. return (currentState = {}, action = {}) =>
  10. reducers.reduce((updatedState, red) => red(updatedState, action), currentState);
  11. }
Add Comment
Please, Sign In to add comment