ngrx-workshop
Search…
3 Types of Actions
  • Commands
  • Documents
  • Events
// Effect Action Types Example
@Effect()
insert: Observable<Action> = this.actions$.pipe(
ofType<InsertUser>(UserActionTypes.InsertUser), // command
exhaustMap(action =>
this.service.create(action.payload.user).pipe(
map((user: User) => new InsertUserSuccess({ result: user })), // document
catchError(() => of(new UserActionFail(
{ error: 'Error inserting user.' }))) // event
)
)
);
Copy link