Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ofType with more than 5 actions?

I have to use ofType with more than 5 actions in my effect.

@Effect()
  applyInspectionsFilters$: Observable<Action> = this.actions$.pipe(
    ofType(
      InspectionsPageActions.applyInspectionsFilters.type,
      InspectionsPageActions.clearSelectedInspectionsFilters.type,
      InspectionsPageActions.removeSelectedStatusFilter.type,
      InspectionsPageActions.removeSelectedAttributeFilter.type,
      InspectionsPageActions.removeSelectedUserFilter.type,
      InspectionsPageActions.removeNotAssignedUsersFilter.type
    ),
    withLatestFrom(
      this.store$.pipe(select(fromInspections.getSelectedInspectionsFilters))
    ),
    switchMap(([action, filters]) =>
      ...
    )
  );

How should I do this when the maximum number of parameters is 5 in their library?

like image 855
Sergiu Molnar Avatar asked Aug 01 '19 08:08

Sergiu Molnar


1 Answers

docs here: https://ngrx.io/api/effects/ofType

show the way to do it is something like this:

ofType(
  ...[InspectionsPageActions.applyInspectionsFilters.type,
  InspectionsPageActions.clearSelectedInspectionsFilters.type,
  InspectionsPageActions.removeSelectedStatusFilter.type,
  InspectionsPageActions.removeSelectedAttributeFilter.type,
  InspectionsPageActions.removeSelectedUserFilter.type,
  InspectionsPageActions.removeNotAssignedUsersFilter.type]
),
like image 200
bryan60 Avatar answered Nov 05 '22 03:11

bryan60