RxJava



rx.operators
Class OperationOnErrorReturn<T>

java.lang.Object
  extended by rx.operators.OperationOnErrorReturn<T>

public final class OperationOnErrorReturn<T>
extends java.lang.Object

Instruct an Observable to emit a particular item to its Observer's onNext method rather than invoking onError if it encounters an error.

By default, when an Observable encounters an error that prevents it from emitting the expected item to its Observer, the Observable invokes its Observer's onError method, and then quits without invoking any more of its Observer's methods. The onErrorReturn operation changes this behavior. If you pass a function (resumeFunction) to onErrorReturn, if the original Observable encounters an error, instead of invoking its Observer's onError method, it will instead pass the return value of resumeFunction to the Observer's onNext method.

You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.


Constructor Summary
OperationOnErrorReturn()
           
 
Method Summary
static
<T> Observable.OnSubscribeFunc<T>
onErrorReturn(Observable<? extends T> originalSequence, Func1<java.lang.Throwable,? extends T> resumeFunction)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperationOnErrorReturn

public OperationOnErrorReturn()
Method Detail

onErrorReturn

public static <T> Observable.OnSubscribeFunc<T> onErrorReturn(Observable<? extends T> originalSequence,
                                                              Func1<java.lang.Throwable,? extends T> resumeFunction)