Last active
January 11, 2016 10:10
-
-
Save lancetw/2434b7ddf6fd4dc6b634 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// borrow from react-redux-starter-kit | |
// https://github.com/davezuko/react-redux-starter-kit | |
export function createConstants (...constants) { | |
return constants.reduce((acc, constant) => { | |
return Object.assign({}, acc, { [constant]: constant }) | |
}, {}) | |
} | |
export function createReducer (initialState, reducerMap) { | |
return (state = initialState, action) => { | |
const reducer = reducerMap[action.type] | |
return reducer ? Object.assign({}, state, reducer(state, action)) : state | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment