Pass whole action to reducerBranch

context-store
Alfred Melch 5 years ago
parent 4b98f6f654
commit 653627033a

@ -39,9 +39,9 @@ export const createStore = options => {
function makeReducerFn(reducer, { onUpdate, logging }) { function makeReducerFn(reducer, { onUpdate, logging }) {
const noop = state => state const noop = state => state
return (prevState, action) => { return (prevState, action) => {
const { type, ...payload } = action const { type } = action
const reducerBranch = reducer[type] || reducer['default'] || noop const reducerBranch = reducer[type] || reducer['default'] || noop
const nextState = reducerBranch(prevState, payload) const nextState = reducerBranch(prevState, action)
const stats = { prevState, nextState, action } const stats = { prevState, nextState, action }
typeof onUpdate === 'function' && onUpdate(stats) typeof onUpdate === 'function' && onUpdate(stats)
if (logging) logger(stats) if (logging) logger(stats)

Loading…
Cancel
Save