Created
June 2, 2016 08:35
-
-
Save farism/0aad15dd15b023ab9027b613ab8b3c0e to your computer and use it in GitHub Desktop.
handleLocalActions
This file contains hidden or 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
export const handleLocalActions = (reducers) => { | |
const reducer = (state, action) => { | |
if (!action.me) { | |
return state; | |
} | |
const { meta: { type }, payload } = action; | |
if (!reducers[type]) { | |
return state; | |
} | |
return reducers[type](state, { type, payload }); | |
}; | |
reducer.getActionTypes = () => Object.keys(reducers); | |
return reducer; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment