[英]RxJS concatMap subscription is called for second Observable separately
[英]rxjs concatMap does not seem to be called
沒有調用第二個concatMap
。
this.apiService.get()
.pipe(
concatMap((data: MyModel) => {
if (data) {
// the following returns a MyModel Observable
return this.apiService.update(data);
} else {
return empty();
}
}),
concatMap((data: MyModel) => this.apiService.update(this.myOtherData))
)
.subscribe(data => log('completed'));
有任何想法嗎?
你得加倍管。 在這里看看: https : //github.com/reactivex/rxjs/issues/4071
timer(10).pipe(
concatMap(() => from(wait(20)).pipe(
concatMap(() => {
console.log('here');
return from(wait(20)).pipe(
tap(x => console.log('>', x))
);
})
))
)
.subscribe(x => console.log('>', x));
您知道concatMap如何要求可觀察到的返回嗎? 好吧,我剛剛了解到,如果該源存在問題,則可觸發的concatMap不會觸發。 當不是問題的原因時,我很想嘗試對concatMap進行故障排除。
我也通過發送一個空的Observable來確保設置正確,這也是我解決問題的方法。
this.sendRequest({'search': "be"}).pipe(
concatMap(options => {
console.log(options);
return of([]);
})
).subscribe(data => {
console.log(data);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.