ngrx-workshop
Search…
3 Types of Actions
  • Commands
  • Documents
  • Events
1
// Effect Action Types Example
2
@Effect()
3
insert: Observable<Action> = this.actions$.pipe(
4
ofType<InsertUser>(UserActionTypes.InsertUser), // command
5
exhaustMap(action =>
6
this.service.create(action.payload.user).pipe(
7
map((user: User) => new InsertUserSuccess({ result: user })), // document
8
catchError(() => of(new UserActionFail(
9
{ error: 'Error inserting user.' }))) // event
10
)
11
)
12
);
Copied!
Last modified 2yr ago
Copy link