O'Reilly logo

Mastering Reactive JavaScript by Erich de Souza Oliveira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The mergeDelayError() operator

The last operator that deals with errors in this chapter is the mergeDelayError() operator. When you merge two or more observables (using the merge() operator), if an error is propagated from one of the observables, it will be propagated to the generated observable stopping it, as you can see in the following example:

var observableWithError = Rx.Observable.create(function(source){   source.onNext('hello');   source.onError(new Error('An error occurred'));   source.onNext('hello again');   source.onCompleted(); }); Rx.Observable.merge(   observableWithError,   Rx.Observable.interval(100).take(4) ).subscribe(   (m)=>console.log(m),   (e)=>console.log('Error') ); 

In this example, we create an Observable that emits a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required