在Angular Reducer之间共享数据

时间:2020-09-30 11:50:31

标签: angular redux ngrx

我的应用程序中存在一种情况,需要在减速器之间共享数据。

State:
{
   ...
   itemDetails,
   settings
}

itemDetails存储中,我需要更新一些数据,并且要执行此操作,我需要settings存储中的一些数据。

(我也在使用外墙。)

是否有可能在类似反应的redux-thunk之类的减速器之间共享数据?

我还有其他两种选择可以做到这一点:

  1. 将该设置数据作为功能参数发送到Facade方法。
  2. settingsFacades中插入itemDetailsFacades,然后直接在操作中发送这些数据。

但是我很好奇在减速器之间是否有一种更优雅的共享数据的方法。

1 个答案:

答案 0 :(得分:1)

通常,您只能访问商店以获取数据。例如,效果看起来像这样

constructor(private store$: Store<AppState>) {}

@Effect() specialEffect$ = this.actions$
    .ofType(SOME_ACTION)
    .withLatestFrom(this.store$)
    .map(([action: Action, storeState: AppState]) => {
      // Do something ... use selectors, dispatch action etc.
    });
相关问题