Pass whole action to reducerBranch
This commit is contained in:
		
							parent
							
								
									4b98f6f654
								
							
						
					
					
						commit
						653627033a
					
				@ -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)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user