Skip to content

Instantly share code, notes, and snippets.

@a-eid
Created November 14, 2016 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-eid/3db3635ed5c28ec0aa269a08eefb85c4 to your computer and use it in GitHub Desktop.
Save a-eid/3db3635ed5c28ec0aa269a08eefb85c4 to your computer and use it in GitHub Desktop.
difference btw comibineReducers with map and reduce ?
const combineReducers = (reducers)=>{
return (state = {} , action)=>{
Object.keys(reducers).reduce(function( nextState , key ){
nextState[key] = reducers[key](state[key] , action);
return nextState;
} , {})
}
}
const combineReducers = (reducers)=>{
return (state , action){
const nextState = {}
Object.keys(reducers).map((state , action)=>{
nextState[key] = state[key](state[key] , action)
})
return nextState
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment