你好,如何将有效载荷参数从mergeMap传递给switchMap?我在clientservice.checkValideName中使用它,但希望将它传递给sendMessage(data,payload1)。
我试过很多东西,但都没有用。(另一次合并或映射checkValideName的结果以注入有效载荷)
@Effect() CheckValidatedName$ = this.actions$.pipe(
ofType(CheckValidatedActionTypes.VALIDATED_NAME),
map((action: ValidatedNameAction) => action.payload),
withLatestFrom(this.store.select(fromRoot.selectors.getCurrentClient)),
mergeMap(([payload, client]) =>
this.clientService.checkValideName(client.uuid, payload[0])
),
map((result: any) => result.data),
switchMap((data: boolean) => {
return of(this.sendMessage(data))
}),
catchError((res: any) => this.catchResponseError(res)));
发布于 2018-10-25 11:57:20
您可以将它作为mergeMap响应的一部分返回--这是管道中丢失它的地方:
mergeMap([payload, client] => {
// now we have it, and after returning clientServiceCheck, we lose the reference to it
return this.clientService(checkValidname(client, payload));
})
.map(result => result.data)相反,您希望返回结果和数据,大致如下所示:
mergeMap([payload, client] => {
// now we have it, and after returning clientServiceCheck, we lose the reference to it
return mergeMap(() => [
of(payload)
this.clientService(checkValidname(client, payload)),
]);
})
.map([payload, result] => {
// now we have both
})https://stackoverflow.com/questions/52988528
复制相似问题