June 2017
Intermediate to advanced
400 pages
8h 44m
English
Another way to attempt recovery is to use the retry() operator, which has several parameter overloads. It will re-subscribe to the preceding Observable and, hopefully, not have the error again.
If you call retry() with no arguments, it will resubscribe an infinite number of times for each error. You need to be careful with retry() as it can have chaotic effects. Using it with our example will cause it to emit these integers infinitely and repeatedly:
import io.reactivex.Observable;public class Launcher { public static void main(String[] args) { Observable.just(5, 2, 4, 0, 3, 2, 8) .map(i -> 10 / i) .retry() .subscribe(i -> System.out.println("RECEIVED: " + i), e -> System.out.println("RECEIVED ERROR: " + e) ); }}
The output of the ...
Read now
Unlock full access