onErrorReturn method

Observable<CommandResult<TResult>> onErrorReturn (CommandResult<TResult> 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.

Example

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

Implementation

Observable<T> onErrorReturn(T returnValue) =>
    transform(new OnErrorResumeNextStreamTransformer<T>(
        new Observable<T>.just(returnValue)));