我怎样才能做一个 switchMap 并在订阅中获得不同的响应?

how can I do a switchMap and get the diferent responses in the subscription?

如何使用 RXJS 实现以下目标? 我有 3 个请求,每个请求都依赖于前一个,我需要订阅中的所有响应。

this.httpService.request1(paramsObj).pipe(
    switchMap((response)=>{
        return this.httpService.request2({...response})
    }),
    switchMap((response)=>{
        return this.httpService.request3({...response})
    })
).subscribe(([response1, response2, response3]) => {
   // somehow access all responses here while each response is dependeant on the previous one
})

您可能需要像下面这样手动传递它

this.httpService.request1(paramsObj).pipe(
    switchMap((res1)=>{
        return this.httpService.request2({...res1}).pipe(map(res2=>[res1,res2]))
    }),
    switchMap(([res1,res2)=>{
        return this.httpService.request3({...res2}).pipe(map(res3=>[res1,res2,res3]))
    })
).subscribe(([res1, res2, res3]) => {

})