我在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));
})
);
取出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));
})
);