Skip to content

Instantly share code, notes, and snippets.

@mijms
Created July 21, 2021 13:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mijms/39eed4d2df7836ebf268bae20bd70c9a to your computer and use it in GitHub Desktop.
Save mijms/39eed4d2df7836ebf268bae20bd70c9a to your computer and use it in GitHub Desktop.
Reducer builder function sample
export const buildReducers = (name)=>{
const handlers = {
[`set_main_${name}`]: mainHandlers.set_main,
};
return {
[name]: (state = {}, action)=>( get(handlers, action.type, d => d)(state, action))
}
}
// buildReducer('app_name')
// ['app1', 'app2', 'app3'].map(app=>(buildReducer(app)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment