These are chat archives for ReactiveX/RxJava

Mar 2017
Ertan Deniz
Mar 17 2017 12:36


I'm pretty new in RxJava and stumbled into a problem. I have a getData method which gets data from a RESTFul service with cursor/pagination support. The following code, when there's an exception in getData starts the whole process from the beginning, but would it be possible to just retry the failed getData with the specific cursor?

How should I rewrite this code?

Flowable<Response> f = Flowable.create(emitter -> {
    long cursor = -1;
    Response response;

    do {
        response = getData(cursor);

        cursor = response.getNextCursor();
    } while (response.hasNext());

}, BackpressureStrategy.BUFFER);

f.retryWhen(errors -> {
    return errors.zipWith(Flowable.range(1, 5), (err, attempt) -> {
        return Flowable.timer(2 * attempt, TimeUnit.SECONDS);