Skip to content

Instantly share code, notes, and snippets.

@farism
Created June 2, 2016 08:35
Show Gist options
  • Save farism/0aad15dd15b023ab9027b613ab8b3c0e to your computer and use it in GitHub Desktop.
Save farism/0aad15dd15b023ab9027b613ab8b3c0e to your computer and use it in GitHub Desktop.
handleLocalActions
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