Pass whole action to reducerBranch

This commit is contained in:
Alfred Melch 2020-02-01 18:09:03 +01:00
parent 4b98f6f654
commit 653627033a

View File

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