Created
July 13, 2017 17:04
-
-
Save vsavkin/22ae4f139b69b8c127baffff7ad644b1 to your computer and use it in GitHub Desktop.
This file contains 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
class TodosEffects { | |
constructor(private actions: Actions, private http: Http) {} | |
@Effect() addTodo = this.actions.ofType('ADD_TODO'). | |
concatMap(todo => this.http.post(…). | |
map(() => ({type: 'TODO_ADDED', payload: todo}))); | |
} | |
function todosReducer(todos: Todo[] = [], action: any): Todo[] { | |
if (action.type === 'TODO_ADDED') { | |
return [...todos, action.payload]; | |
} else { | |
return todos; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment