Modify Source Observable on retry - RxJava

rx-java

Solution

Use `defer`. This would allow `ids` to be re-computed:

Observable.defer(() -> {
    List<String> ids = // compute this somehow
    return Observable.from(ids);
}).retryWhen(...

Documentation on the defer operator

Problem

How do i update a source observable on retry? ``` List<String> ids = new ArrayList<>(); // A,B,C Observable.from(ids) .retryWhen(errors -> { return errors .zipWith(Observable.range(0, 1), (n, i) -> i) .flatMap(retryCount -> Observable.timer((long) Math.pow(2, retryCount), TimeUnit.MINUTES)); }) .subscribe(....); ``` now rather than passing //A,B,C as ids if i want to pass some other values. How do i do it? or is this even the right approach?

Original source