onErrorResumeNext
is an operator in RxJS that enables an Observable to continue emitting values even if there's an error. Here's an example on how to use it in TypeScript:
index.ts737 chars24 lines
In this example, source$
is an Observable that emits 'value 1', 'value 2', throws an error, and then emits 'value 3'. fallback$
is a fallback Observable that emits 'fallback value'. Using the onErrorResumeNext
operator, we can combine these two Observables so that even if source$
throws an error, fallback$
will continue emitting values.
The output of the above code would be:
index.ts40 chars5 lines
As you can see, even if source$
throws an error, fallback$
emits 'fallback value' and the Observable completes normally.
gistlibby LogSnag