Skip to content

Instantly share code, notes, and snippets.

@Emilios1995
Created March 30, 2017 03:28
Show Gist options
  • Save Emilios1995/d9a1bbf6c68381cd4ba017ceb6f4421b to your computer and use it in GitHub Desktop.
Save Emilios1995/d9a1bbf6c68381cd4ba017ceb6f4421b to your computer and use it in GitHub Desktop.
const createReducer = (initialState, map) =>
(state = initialState, action) =>
(map[action.type])
? map[action.type](state)
: state
const reducer = createReducer(0, counterMap)
reducer(0, {type: "increment"}) // => 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment