Created
November 21, 2019 14:57
-
-
Save akarnokd/acff7ab937838467d6b8da90d1974900 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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