Created
July 21, 2021 13:10
-
-
Save mijms/39eed4d2df7836ebf268bae20bd70c9a to your computer and use it in GitHub Desktop.
Reducer builder function sample
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
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