【发布时间】:2018-12-11 11:07:50
【问题描述】:
我想知道一个接一个地发出http请求时的最佳做法是什么,特别是,我将被要求使用第一个请求的返回值。目前,我有一个嵌套订阅来解决这个问题[参见下面的代码]。
我尝试使用 RxJS 的 siwtchMap、mergeMap 和 concat,但它似乎不起作用。任何建议都会有所帮助。
onStartUp() {
this.recordingService.getRecording(this.id)
.subscribe(x => {
this.recording = x;
const params = new Chunk(this.recording, 0, 30);
this.recordingService.getSignal(params)
.subscribe(data => console.log(data));
});
}
【问题讨论】:
-
什么不适用于
switchMap或mergeMap?