2

I would like to use the onErrorResumeNext feature of RxJS, i.e. to continue to receive events even if an error is received (instead of terminating).

But I can see in the following doc that there is no correspondance in RxJS5: https://github.com/ReactiveX/RxJS/blob/master/MIGRATION.md.

Is there a workaround to use such feature? Thanks!

Thierry Templier
  • 198,364
  • 44
  • 396
  • 360

2 Answers2

1

I've been looking for that operator too! I came up with a solution for my needs that I hope will help yours. It's not the best solution most likely, but I hope it can help until a better solution can be found by some others on here, or until this operator is added back in 5.0 (hopefully!) :)

var Observable = Rx.Observable;

var source1 = Observable.create(function(observer){
    observer.error();
});
var source2 = Observable.create(function(observer){
    observer.next('Continuing on');
    observer.complete();
});


var stream = source1.catch(function(data){
  return source2;
});



stream.subscribe(function(data){
  console.log(data);
});

JS Bin Example: https://jsbin.com/qadozoveta/edit?html,js,console

Daniel Ram
  • 352
  • 2
  • 6
0

You can use the following in rxjs5 still.

 Observable.onErrorResumeNext(observable1$, observable2$, observable3$...)
           .subscribe(() => { ... })

onErrorResumeNext source code

schrodinger's code
  • 2,624
  • 1
  • 25
  • 19