Skip to content

Instantly share code, notes, and snippets.

@lydemann
Created February 19, 2019 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lydemann/8bdee9dca899f224cd89ee03faea0e1e to your computer and use it in GitHub Desktop.
Save lydemann/8bdee9dca899f224cd89ee03faea0e1e to your computer and use it in GitHub Desktop.
todo-list.effects.ts
@Injectable()
export class TodoListEffects {
constructor(private actions$: Actions, private todoListService: TodoListService) {}
@Effect()
loadTodoList$ = this.actions$.pipe(
ofType(TodoListActionTypes.LoadTodoList),
exhaustMap(() => this.todoListService.getTodos()),
map((todoList) => new TodoItemsLoaded(todoList)),
catchError((error: Error) => of(new TodoItemsLoadFailed(error)))
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment