onErrorResume method

Observable<T> onErrorResume (Stream<T> recoveryFn(dynamic error))

Intercepts error events and switches to a recovery stream created by the provided recoveryFn.

The onErrorResume operator intercepts an onError notification from the source Observable. Instead of passing the error through to any listeners, it replaces it with another Stream of items created by the recoveryFn.

The recoveryFn receives the emitted error and returns a Stream. You can perform logic in the recoveryFn to return different Streams based on the type of error that was emitted.

If you do not need to perform logic based on the type of error that was emitted, please consider using onErrorResumeNext or onErrorReturn.

Example

new Observable<int>.error(new Exception())
  .onErrorResume((dynamic e) =>
      new Observable.just(e is StateError ? 1 : 0)
  .listen(print); // prints 0

Implementation

Observable<T> onErrorResume(Stream<T> Function(dynamic error) recoveryFn) =>
    transform(new OnErrorResumeStreamTransformer<T>(recoveryFn));