Angular NgXs - 正在触发另一个动作

Angular NgXs - action is being triggered the other action

我有两个动作:

以及在其构造函数中分派操作的组件:

this.store.dispatch(new CountriesGetList({ object: this.object, objectId: this.objectId }));

问题是这个调度触发了这个动作@Action(CountriesGetList) 和...另一个动作:

@Action(CitiesGetList)
columns_get_list({ getState, patchState }: StateContext<StateModel>, action: CitiesGetList) {}

问题是:为什么会这样?我不需要发送第二个动作 - @Action(CitiesGetList).

感谢提前!

这将需要更多信息才能重现,但对此最合乎逻辑的解释是您对这两个操作使用相同的 static type 值。所以我猜你是这样声明的:

export class CountriesGetList {
  static type = '[Countries] Get List';
  // ...
}

export class CitiesGetList{
  static type = '[Countries] Get List';
  // ...
}

您应该更新您的城市操作以具有唯一类型 属性:

export class CitiesGetList{
  static type = '[Cities] Get List';
  // ...
}