Skip to content

Instantly share code, notes, and snippets.

@akarnokd
Created November 21, 2019 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akarnokd/acff7ab937838467d6b8da90d1974900 to your computer and use it in GitHub Desktop.
Save akarnokd/acff7ab937838467d6b8da90d1974900 to your computer and use it in GitHub Desktop.
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import io.reactivex.Observable;
public class RetryWhenDelay {
@Test
public void test() throws Exception {
Observable<Integer> call = Observable.create(emitter -> {
emitter.onNext(1);
emitter.onError(new Throwable("Error"));
});
call
.retryWhen(throwableObservable -> throwableObservable.delay(1, TimeUnit.SECONDS))
.subscribe(integer -> System.out.println(integer), throwable -> System.out.println(throwable.getMessage()));
Thread.sleep(10000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment