Skip to content

Instantly share code, notes, and snippets.

@lydemann
Created December 24, 2019 13:54
Show Gist options
  • Save lydemann/d3475ea7378f1e784577cf28a67b1091 to your computer and use it in GitHub Desktop.
Save lydemann/d3475ea7378f1e784577cf28a67b1091 to your computer and use it in GitHub Desktop.
todo-list.effects.ts
@Injectable()
export class TodoListEffects {
public getTodoListRequest$ = createEffect(() =>
this.actions$.pipe(
ofType(TodoListActions.getTodoListRequest),
exhaustMap(() =>
this.todoListResourcesService.getTodos().pipe(
map(todoList => TodoListActions.getTodoListResponse({ todoList })),
catchError((error: Error) =>
of(TodoListActions.getTodoListFailed({ error })),
),
),
),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment