Skip to content

Commit

Permalink
Allow multiple side effects
Browse files Browse the repository at this point in the history
When using UpdateWithSideEffect allow passing in a function or array of functions
  • Loading branch information
hasnat committed Aug 4, 2019
1 parent df4f5f0 commit eac6b68
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.js
Expand Up @@ -34,7 +34,10 @@ function finalReducer(reducer) {
}
let { newState, newSideEffect } = reducer(state.state, action);
const newSideEffects = newSideEffect
? [...state.sideEffects, newSideEffect]
? [
...state.sideEffects,
Array.isArray(newSideEffect) ? ...newSideEffect : newSideEffect
]
: state.sideEffects;
return {
state: newState || state.state,
Expand Down

0 comments on commit eac6b68

Please sign in to comment.