The 2nd concatMap
does not get called.
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'));
any ideas?
You'd have to double pipe. Take a look here: 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));
You know how concatMap requires an observable to return? Well I just learned that if there is an issue with that source observable concatMap won't fire. I was stumped trying to troubleshoot concatMap when it wasn't the cause.
This is how I troubleshot it too, by sending an empty observable to make sure my setup was correct.
this.sendRequest({'search': "be"}).pipe(
concatMap(options => {
console.log(options);
return of([]);
})
).subscribe(data => {
console.log(data);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.