src/main/java/io/reactivex/Completable.java
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final Completable retryWhen(Function<? super Flowable<Throwable>, ? extends Publisher<?>> handler) {
        return fromPublisher(toFlowable().retryWhen(handler));
    }
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final Completable retryWhen(Function<? super Flowable<Throwable>, ? extends Publisher<?>> handler) {
        return fromPublisher(toFlowable().retryWhen(handler));
    }
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Completable retryWhen ( Function < ? super Flowable < Throwable > , ? extends Publisher < ? > > handler ) { return fromPublisher ( toFlowable ( ) . retryWhen ( handler ) ) ; }
Returns a Completable which given a Publisher and when this Completable emits an error, delivers
that error through a Flowable and the Publisher should signal a value indicating a retry in response
or a terminal event indicating a termination.
<p>
<img width="640" height="586" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Completable.retryWhen.png" alt="">
<p>
Note that the inner {@code Publisher} returned by the handler function should signal
either {@code onNext}, {@code onError} or {@code onComplete} in response to the received
{@code Throwable} to indicate the operator should retry or terminate. If the upstream to
the operator is asynchronous, signalling onNext followed by onComplete immediately may
result in the sequence to be completed immediately. Similarly, if this inner
{@code Publisher} signals {@code onError} or {@code onComplete} while the upstream is
active, the sequence is terminated with the same signal immediately.
<p>
The following example demonstrates how to retry an asynchronous source with a delay:
<pre><code>
Completable.timer(1, TimeUnit.SECONDS)
.doOnSubscribe(s -&gt; System.out.println("subscribing"))
.doOnComplete(() -&gt; { throw new RuntimeException(); })
.retryWhen(errors -&gt; {
AtomicInteger counter = new AtomicInteger();
return errors
.takeWhile(e -&gt; counter.getAndIncrement() != 3)
.flatMap(e -&gt; {
System.out.println("delay retry by " + counter.get() + " second(s)");
return Flowable.timer(counter.get(), TimeUnit.SECONDS);
});
})
.blockingAwait();
</code></pre>
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code retryWhen} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>
@param handler the handler that receives a Flowable delivering Throwables and should return a Publisher that
emits items to indicate retries or emits terminal events to indicate termination.
@return the new Completable instance
@throws NullPointerException if handler is null
Returns a Completable which given a Publisher and when this Completable emits an error delivers that error through a Flowable and the Publisher should signal a value indicating a retry in response or a terminal event indicating a termination . <p > <img width = 640 height = 586 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Completable . retryWhen . png alt = > <p > Note that the inner {