Skip to content

Instantly share code, notes, and snippets.

@chris-burgin
Created April 16, 2017 23:34
Show Gist options
  • Save chris-burgin/fc4f04b7db09b1b46c8c017304ce6d89 to your computer and use it in GitHub Desktop.
Save chris-burgin/fc4f04b7db09b1b46c8c017304ce6d89 to your computer and use it in GitHub Desktop.
Object Literal Redux Store Reducer
// ****************
// 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