Redux 使用@ngrx/store访问reducer中的其他状态片

Redux 使用@ngrx/store访问reducer中的其他状态片,redux,ngrx,ngrx-effects,ngrx-store-4.0,Redux,Ngrx,Ngrx Effects,Ngrx Store 4.0,鉴于以下情况(假设我们无法改变州的结构): 而b1Reducer取决于a的值(例如,因为它包含类似用户信息的内容)。 在b1Reducer中访问(只读)a最惯用的方式是什么 我提出的解决方案是使用@ngrx/effects,使用a调度另一个可以在减速器中使用的操作: @Effect() augmentAction$ = this.action$ .ofType(Actions.Action1) .withLatestFrom(this.store$) .switchMap

鉴于以下情况(假设我们无法改变州的结构):

b1Reducer
取决于
a
的值(例如,因为它包含类似用户信息的内容)。 在
b1Reducer
中访问(只读)
a
最惯用的方式是什么

我提出的解决方案是使用
@ngrx/effects
,使用
a
调度另一个可以在减速器中使用的操作:

@Effect()
augmentAction$ = this.action$
    .ofType(Actions.Action1)
    .withLatestFrom(this.store$)
    .switchMap(([action, state]:[Action, AppState]) => {
        const a = state.a;
        return [new Actions.Action2(a)];
    });
这是可行的,但是如果
a
在许多减速机中使用,那么几乎每一个操作都需要重新修补,那么就很难管理了。有没有更好的方法来处理这个问题

@Effect()
augmentAction$ = this.action$
    .ofType(Actions.Action1)
    .withLatestFrom(this.store$)
    .switchMap(([action, state]:[Action, AppState]) => {
        const a = state.a;
        return [new Actions.Action2(a)];
    });