onErrorReturn method

Observable<T> onErrorReturn(
  1. T returnValue

instructs an Observable to emit a particular item when it encounters an error, and then terminate normally

The onErrorReturn operator intercepts an onError notification from the source Observable. Instead of passing it through to any observers, it replaces it with a given item, and then terminates normally.

If you need to perform logic based on the type of error that was emitted, please consider using onErrorReturnWith.


new Observable.error(new Exception())
  .listen(print); // prints 1


Observable<T> onErrorReturn(T returnValue) =>
        (dynamic e) => Observable<T>.just(returnValue)));