【问题标题】:Is there a way to trigger an 'basic' action for an dispatched action in ngrx?有没有办法为ngrx中的已调度操作触发“基本”操作?
【发布时间】:2022-01-20 04:51:05
【问题描述】:

我有以下情况:

当以下这些操作之一被调度时,我想将reducer 中的saving 设置为true。但目前我没有在减速器中“捕捉”这些动作。我只是在我的effects 中“捕捉”这些。现在我有一个问题,是否可以创建一个“基本”动作,当我在下面调度我的动作时会自动调用它?如果可能的话,我想在我的reducer 中捕捉这些“基本”操作,以更改saving 的值。

/**
 * Update Match Conditions
 */
export const updateMatchConditions = createAction(
  AccountMatchingPageConstants.UPDATE_MATCH_CONDITIONS,
  props<{ accountId: string, connection: Connection, matchConditionUpdate: MatchConditionUpdate[] }>()
);

/**
 * Reset Match Conditions
 */
export const resetMatchConditions = createAction(
  AccountMatchingPageConstants.RESET_MATCH_CONDITIONS,
  props<{ accountId: string, connection: Connection }>()
);

【问题讨论】:

    标签: javascript angular typescript ngrx


    【解决方案1】:

    你可以这样做:

      loremIpsum$ = createEffect(() =>
        this.actions$.pipe(
          ofType(updateMatchConditions),
          map(() =>
            basicActions.loremIpsum()
          )
        )
      );
    

    【讨论】:

      猜你喜欢
      • 2023-03-14
      • 2021-11-08
      • 1970-01-01
      • 1970-01-01
      • 2016-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-14
      相关资源
      最近更新 更多