如何通过5个以上的动作使用ofType?

时间:2019-08-01 08:31:18

标签: angular typescript ngrx ngrx-effects

我必须使用ofType并执行5次以上的操作。

@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]) =>
      ...
    )
  );

当它们的库中参数的最大数量为5时,该怎么办?

1 个答案:

答案 0 :(得分:5)

文档在这里:https://ngrx.io/api/effects/ofType

显示执行该操作的方法是这样的:

ofType(
  ...[InspectionsPageActions.applyInspectionsFilters.type,
  InspectionsPageActions.clearSelectedInspectionsFilters.type,
  InspectionsPageActions.removeSelectedStatusFilter.type,
  InspectionsPageActions.removeSelectedAttributeFilter.type,
  InspectionsPageActions.removeSelectedUserFilter.type,
  InspectionsPageActions.removeNotAssignedUsersFilter.type]
),