Created
October 11, 2017 10:01
-
-
Save nomanHasan/7eb365f0a1253587329fbb7a133cbe3f to your computer and use it in GitHub Desktop.
6 #todoapp-angular-ngrx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ........................ | |
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