我有2个观察者,第2个观察者以第1个作为参数。代码看起来如下,但o2$
怎么能回归o1$
?
let o1$ = this.apiService.get1();
let o2$ = this.apiService.get2();
o1$.pipe(
map(data => data['id']),
concat(o2$)
).subscribe(x => log('completed'));
您可以在这里使用flatMap
,如下所示:
let o1$ = this.apiService.get1();
o1$.pipe(
flatMap(data => this.apiService.get2(data['id'])),
).subscribe(x => log('completed'));