|
|
|
@ -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)
|
|
|
|
|