NGRX效果里面获得国家和有效载荷数据一起

问题描述 投票:1回答:1

我在NGRX状态保存的一些小部件实例(第三方非角库),我需要与用户行为的新PARAMS窗口更新。对于这种情况,我派遣新的小部件PARAMS作为有效载荷的动作。

它有可能获得在同一个地方的效果有效载荷和状态数据,无需额外的私人领域?

@Effect({ dispatch: false })
public updateStatistics: Observable<webChatActions.Actions> = this._actions.pipe(
    ofType(Types.UPDATE_STATISTICS),
    map((action: demoActions.UpdateStatistics) => action.payload),
    tap((payload: StatisticsOptions) => console.log(payload)),
    withLatestFrom(this._store),
    map(([action, state]): DemoEffects => state['web-chat']),
    tap((state: WebChatState) => {
    // here I have my state, but also I need payload from tap above
    }),
    catchError((error: Error) => {
        this._logger.error('unable to update feedback widget', error);
        return of(new webChatActions.Service.ShowChatError(error));
    })
);
rxjs state ngrx chaining payload
1个回答
1
投票

取出map和你有它。

@Effect({ dispatch: false })
public updateStatistics: Observable<webChatActions.Actions> = this._actions.pipe(
    ofType(Types.UPDATE_STATISTICS),
    map((action: demoActions.UpdateStatistics) => action.payload),
    tap((payload: StatisticsOptions) => console.log(payload)),
    withLatestFrom(this._store),
    map((): DemoEffects => state['web-chat']),
    tap(([action, state]) => {
      // action.payload 
      // tate['web-chat']
    }),
    catchError((error: Error) => {
        this._logger.error('unable to update feedback widget', error);
        return of(new webChatActions.Service.ShowChatError(error));
    })
);
© www.soinside.com 2019 - 2024. All rights reserved.