Skip to content

Instantly share code, notes, and snippets.

View chiefGui's full-sized avatar
:shipit:
Shipping stuff

Guilherme Oderdenge chiefGui

:shipit:
Shipping stuff
View GitHub Profile
const todos = (state = INITIAL_STATE, action) => reswitch(
ADD_TODO,
[...state.todos, action.todo],
REMOVE_TODO,
() => state.todos.filter(todo => todo.id !== action.todo.id)
)(state, action.type)
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,