Ignoring the error 

As we saw in the former section, the catch() operator does a good job of ensuring that a stream that errors out doesn't cause any problems when being merged with another stream. The catch() operator enables us to take the error, investigate it, and create a new Observable that will emit a value as though nothing happened. Sometimes, however, you don't want to even deal with streams that error out. For such a scenario, there is a different operator, called onErrorResumeNext():

// error-handling/error-ignore.js
const Rx = require("rxjs/Rx");

let mergedIgnore$ = Rx.Observable.onErrorResumeNext(
Rx.Observable.of(1),
Rx.Observable.throw("err"),
Rx.Observable.of(2)
);

mergedIgnore$.subscribe(data => console.log("merge ignore", data));

The implication of using the onErrorResumeNext() operator is that the second stream, the one that emits an error, gets completely ignored, and the values 1 and 2 get emitted. This is a very nice operator to use if your scenario is only about caring for the streams that do not error out.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.164.149