Skip to content

Instantly share code, notes, and snippets.

@chiefGui
Created March 8, 2017 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chiefGui/067347b89652a600c0ba1c8bc44286e6 to your computer and use it in GitHub Desktop.
Save chiefGui/067347b89652a600c0ba1c8bc44286e6 to your computer and use it in GitHub Desktop.
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