-
-
Save jrgcubano/d60094612cbb0f08cbae245612536cb8 to your computer and use it in GitHub Desktop.
Object Literal Redux Store Reducer
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
// **************** | |
// Reducer Imports | |
// **************** | |
import { | |
// users | |
DELETEUSER, | |
UPDATEUSER, | |
ADDUSER, | |
ADDUSERS | |
} from "./reducers/index.js" | |
// **************** | |
// Switch Logic | |
// **************** | |
const reducerSwitch = { | |
// users | |
"ADDUSER": ADDUSER, | |
"ADDUSERS": ADDUSERS, | |
"DELETEUSER": DELETEUSER, | |
"UPDATEUSER": UPDATEUSER, | |
} | |
// **************** | |
// Reducer Switch | |
// **************** | |
const AppReducers = (state, action) => | |
reducerSwitch[action.type](state, action) // execute the reducer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// ****************
// Reducer Switch
// ****************
const AppReducers = (state, action) =>
reducerSwitch.hasOwnProperty(action.type)
? reducerSwitch[action.type](state, action)
: state