【问题标题】:How to use ofType with more than 5 actions?如何使用超过 5 个动作的 ofType?
【发布时间】:2019-12-09 19:21:41
【问题描述】:

我的效果中必须使用带有 5 个以上动作的 ofType。

@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 时,我应该怎么做?

【问题讨论】:

  • 你在做什么需要一个效果,这不能在reducer中完成吗?

标签: angular typescript ngrx ngrx-effects


【解决方案1】:

此处的文档: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]
),

【讨论】:

    猜你喜欢
    • 2018-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-07
    • 2012-02-23
    • 2010-10-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多