Currently, I am working with rxjs version 5.5.6.
Below is a snippet of code that showcases a specific behavior:
Observable.of(1, 2)
.do(a => {
console.log(a);
let d:string = null;
let r = d.length; // this line throws a null exception
})
.catch(() => {
console.log("error caught");
return Observable.never();
})
.subscribe();
Expected output:
1
error caught
2
error caught
Actual output:
1
error caught
The subscription terminates even though an Observable.never()
is returned in the .catch(...)
method chain.
Any suggestions on how to handle this?
ANOTHER SCENARIO
this.subs = Observable
.merge(this.$searchQuery, this.$lazyQuery)
.do(() => this.loadingPage())
.map(filter => this.buildURL(user, app, filter))
.switchMap(url => this.service.getItemsFromService(url))
.map(response => this.buildPage(response))
.do(page => this.loadedPage(page))
.catch(() => {
this.loadedPage(pojo.Page.EMPTY);
return Observable.never();
})
.takeUntil(this.$unsubscribe)
.subscribe();