Created
February 9, 2017 13:38
-
-
Save msikma/fbe9d7fe756c68df7670fa2585adc995 to your computer and use it in GitHub Desktop.
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
// Here's a simple example reducer, a simplified form of what we're using. | |
// It loads a list of employees. | |
import * as types from '../actions/action-types' | |
const initialState = { | |
hasData: false, | |
isLoading: false, | |
entityList: [], | |
error: null | |
} | |
const reducer = (state = initialState, action) => { | |
switch (action.type) { | |
case types.EMPLOYEES_FETCH_BEGIN: | |
return { | |
...state, | |
isLoading: true, | |
error: null | |
} | |
case types.EMPLOYEES_FETCH_SUCCEEDED: | |
return { | |
...state, | |
hasData: true, | |
isLoading: false, | |
entityList: action.payload.entityList, | |
error: null | |
} | |
case types.EMPLOYEES_FETCH_FAILED: | |
return { | |
...state, | |
isLoading: false, | |
error: action.payload.message | |
} | |
default: | |
return state | |
} | |
} | |
export default reducer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment