Skip to content

Instantly share code, notes, and snippets.

@lydemann
Created February 19, 2019 06:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save lydemann/b4bcfb87bcc57bdb87b13faaa9261e1e to your computer and use it in GitHub Desktop.
todo-list.reducers.ts
export const todoListReducers = (
lastState: TodoListState = new TodoListInitState(),
action: GenericAction<TodoListActionTypes, any>
): TodoListState => {
switch (action.type) {
case TodoListActionTypes.LoadTodoList:
return loadTodoItems(lastState, action);
case TodoListActionTypes.TodoItemsLoaded:
return todoItemsLoaded(lastState, action);
case TodoListActionTypes.TodoItemsLoadFailed:
return todoItemsLoadFailed(lastState, action);
case TodoListActionTypes.TodoItemCreated:
return todoItemCreatedReducer(lastState, action);
case TodoListActionTypes.TodoItemsLoadFailed:
return todoItemsLoadFailed(lastState, action);
case TodoListActionTypes.TodoItemDeleted:
return todoItemDeletedReducer(lastState, action);
case TodoListActionTypes.TodoItemUpdated:
return todoItemUpdatedReducer(lastState, action);
case TodoListActionTypes.TodoItemCompleted:
return todoItemCompletedReducer(lastState, action);
default:
return lastState;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment