@Test public void timer() { ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); try { AtomicInteger count = new AtomicInteger(); TestSubscriber<Object> ts = new TestSubscriber<>(Long.MAX_VALUE); Single.defer(() -> count.incrementAndGet() < 5 ? Single.error(new IOException()) : Single.just(1) ) .retryWhen((e, n) -> Single.timer(100, TimeUnit.MILLISECONDS, executor)) .subscribe(ts); ts.awaitDone(5, TimeUnit.SECONDS) .assertResult(1); assertEquals(count.get(), 5); } finally { executor.shutdown(); } }
@Override public void subscribe(Flow.Subscriber<? super T> subscriber) { RetrySubscriber<T, U> parent = new RetrySubscriber<>(subscriber, whenFunction, source); subscriber.onSubscribe(parent); parent.retry(); }
SingleRetry extends CompletionSingle<T> { @Override public void subscribe(Flow.Subscriber<? super T> subscriber) { RetrySubscriber<T, U> parent = new RetrySubscriber<>(subscriber, whenFunction, source); subscriber.onSubscribe(parent); parent.retry(); } }
SingleRetry extends CompletionSingle<T> { @Override public void subscribe(Flow.Subscriber<? super T> subscriber) { RetrySubscriber<T, U> parent = new RetrySubscriber<>(subscriber, whenFunction, source); subscriber.onSubscribe(parent); parent.retry(); } SingleRetry(Single<T> source,
                BiFunction<? super Throwable, ? super Long, ? extends Flow.Publisher<U>> whenFunction);   SingleRetry(Single<T> source, long count);   SingleRetry(Single<T> source, BiPredicate<? super Throwable, ? super Long> predicate); }
SingleRetry extends CompletionSingle<T> { @Override public void subscribe(Flow.Subscriber<? super T> subscriber) { RetrySubscriber<T, U> parent = new RetrySubscriber<>(subscriber, whenFunction, source); subscriber.onSubscribe(parent); parent.retry(); } SingleRetry(Single<T> source,
                BiFunction<? super Throwable, ? super Long, ? extends Flow.Publisher<U>> whenFunction);   SingleRetry(Single<T> source, long count);   SingleRetry(Single<T> source, BiPredicate<? super Throwable, ? super Long> predicate); @Override void subscribe(Flow.Subscriber<? super T> subscriber); }
SingleRetry extends CompletionSingle<T> { @Override public void subscribe(Flow.Subscriber<? super T> subscriber) { RetrySubscriber<T, U> parent = new RetrySubscriber<>(subscriber, whenFunction, source); subscriber.onSubscribe(parent); parent.retry(); } SingleRetry(Single<T> source,
                BiFunction<? super Throwable, ? super Long, ? extends Flow.Publisher<U>> whenFunction);   SingleRetry(Single<T> source, long count);   SingleRetry(Single<T> source, BiPredicate<? super Throwable, ? super Long> predicate); @Override void subscribe(Flow.Subscriber<? super T> subscriber);  }