我在ngrx状态保存了一些小部件实例(第三方非角库),我需要通过用户操作用新的参数更新小部件。在这种情况下,我使用新的小部件参数作为有效负载来分派操作。
在没有额外的私有字段的情况下,是否有可能在相同的有效位置获得有效负载和状态数据?
@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));
})
);发布于 2019-02-09 01:25:58
移除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));
})
);https://stackoverflow.com/questions/54594372
复制相似问题