Created
March 8, 2017 15:48
-
-
Save chiefGui/067347b89652a600c0ba1c8bc44286e6 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
import reswitch from 'reswitch' | |
import {USERS_GET, USERS_GET__SUCCESS, USERS_GET__FAILURE} from 'consts/users' | |
const INITIAL_STATE = {areLoading: false, hasError: false, users: null} | |
const users(state = INITIAL_STATE, action) => reswitch( | |
USERS_GET, | |
{...defaultState, areLoading: true}, | |
USERS_GET__SUCCESS, | |
{...defaultState, areLoading: false, users: action.users}, | |
USERS_GET__FAILURE, | |
{...defaultState, areLoading: false, hasError: true} | |
)(state, action.type) | |
export default users |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment