@@ -2603,10 +2603,28 @@ public final Single<T> retry(Func2<Integer, Throwable, Boolean> predicate) {
2603
2603
* Returns a Single that emits the same values as the source Single with the exception of an
2604
2604
* {@code onError}. An {@code onError} notification from the source will result in the emission of a
2605
2605
* {@link Throwable} item to the Observable provided as an argument to the {@code notificationHandler}
2606
- * function. If that Observable calls {@code onComplete} or {@code onError} then {@code retry} will call
2607
- * {@code onCompleted} or {@code onError} on the child subscription. Otherwise, this Observable will
2608
- * resubscribe to the source Single.
2609
- *
2606
+ * function.
2607
+ * <p>Emissions from the handler {@code Observable} is treated as follows:
2608
+ * <ul>
2609
+ * <li>If the handler {@code Observable} emits an {@code onCompleted} the {@code retryWhen} will call {@code onError}
2610
+ * with {@code NoSuchElementException} on the child subscription.</li>
2611
+ * <li>If the handler {@code Observable} emits an {@code onError} the {@code retryWhen} will call
2612
+ * {@code onError} with the same Throwable instance on the child subscription.
2613
+ * <li>Otherwise, the operator will resubscribe to the source Single.</li>
2614
+ * </ul>
2615
+ * <p>The {@code notificationHandler} function is called for each subscriber individually. This allows per-Subscriber
2616
+ * state to be added to the error notification sequence.</p>
2617
+ * <pre><code>
2618
+ * single.retryWhen(error -> {
2619
+ * AtomicInteger counter = new AtomicInteger();
2620
+ * return error.takeWhile(e -> counter.incrementAndGet() < 3).map(e -> "retry");
2621
+ * }).subscribe(...);
2622
+ * </code></pre>
2623
+ * <p>
2624
+ * Note that you must compose over the input {@code Observable} provided in the function call because {@retryWhen} expects
2625
+ * an emission of the exception to be matched by an event from the handler Observable.
2626
+ * <p>
2627
+ *
2610
2628
* <img width="640" height="430" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/retryWhen.f.png" alt="">
2611
2629
*
2612
2630
* <dl>
0 commit comments