export function tasksReducer(state = new TasksState(), {payload, type}) {
switch (type) {
case CREATE_TASK_SUCCESS:
return state.merge({
deleted: null,
previous: null,
list: state.deleted && state.deleted.key === payload.key ?
state.previous :
state.list.unshift(payload)
});
case REMOVE_TASK_SUCCESS:
return state.merge({
deleted: payload,
previous: state.list,
list: state.list.filter(task => task.key !== payload.key)