src/main/java/io/reactivex/Single.java
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final Single<T> retryWhen(Function<? super Flowable<Throwable>, ? extends Publisher<?>> handler) {
        return toSingle(toFlowable().retryWhen(handler));
    }
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final Single<T> retryWhen(Function<? super Flowable<Throwable>, ? extends Publisher<?>> handler) {
        return toSingle(toFlowable().retryWhen(handler));
    }
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > retryWhen ( Function < ? super Flowable < Throwable > , ? extends Publisher < ? > > handler ) { return toSingle ( toFlowable ( ) . retryWhen ( handler ) ) ; }
Re-subscribes to the current Single if and when the Publisher returned by the handler
function signals a value.
<p>
If the Publisher signals an onComplete, the resulting Single will signal a NoSuchElementException.
<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>
Single.timer(1, TimeUnit.SECONDS)
.doOnSubscribe(s -&gt; System.out.println("subscribing"))
.map(v -&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);
});
})
.blockingGet();
</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 function that receives a Flowable of the error the Single emits and should
return a Publisher that should signal a normal value (in response to the
throwable the Flowable emits) to trigger a resubscription or signal an error to
be the output of the resulting Single
@return the new Single instance
Re - subscribes to the current Single if and when the Publisher returned by the handler function signals a value . <p > If the Publisher signals an onComplete the resulting Single will signal a NoSuchElementException . <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 > Single . timer ( 1 TimeUnit . SECONDS ) . doOnSubscribe ( s - &gt ; System . out . println ( subscribing )) . map ( v - &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 ) ; } ) ; } ) . blockingGet () ; < / code > < / pre > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code retryWhen } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl >