Skip to content

Instantly share code, notes, and snippets.

@nomanHasan
Created October 11, 2017 10:01
Show Gist options
  • Save nomanHasan/7eb365f0a1253587329fbb7a133cbe3f to your computer and use it in GitHub Desktop.
Save nomanHasan/7eb365f0a1253587329fbb7a133cbe3f to your computer and use it in GitHub Desktop.
6 #todoapp-angular-ngrx
// ........................
export function TodoReducer(state = defaultState, action: Action) {
switch (action.type) {
//...............
case TodoActions.DELETE_TODO: {
return { ...state, ...state.todos.splice(state.todos.indexOf(action.payload), 1) };
}
case TodoActions.DELETE_TODO_SUCCESS: {
return state
}
case TodoActions.DELETE_TODO_ERROR: {
return {
...state,
todos: [
...state.todos,
action.payload
]
}
}
//...............
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment