February 2020
Intermediate to advanced
412 pages
9h 36m
English
Another way to attempt recovery is to use the retry() operator, which has several overloaded versions. 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() without parameters as it can have chaotic effects. Using it with our example will cause it to emit these integers infinitely and repeatedly:
import io.reactivex.rxjava3.core.Observable;public class Ch3_48 { public static void main(String[] args) { Observable.just(5, 2, 4, 0, 3) .map(i -> 10 / i) .retry() .subscribe(i -> System.out.println("RECEIVED: " + i), e -> System.out.println("RECEIVED ERROR: " + e)) ...
Read now
Unlock full access