nomanHasan
10/11/2017 - 10:00 AM

3 #todoapp-angular-ngrx

3 #todoapp-angular-ngrx

// ........................

export function TodoReducer(state = defaultState, action: Action) {

    switch (action.type) {
    
      
      //...............
      
      case TodoActions.CREATE_TODO_SUCCESS: {

            return {
                ...state,
                todos: [
                    ...state.todos.filter(t => {

                        return t._id != "new"
                    }), {
                        ...action.payload,
                        edited: true
                    }, {
                        ...Todo.generateMockTodo(),
                        ...initializeTodoState()
                    }]
            }
        }
        
        // ............
    
    
    }
    
}