Created
January 17, 2018 02:59
-
-
Save ahmedrizwan/eeccafc31b9af42a349aaa8c96f59246 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
Observable.fromPublisher<String> { | |
it.onNext("Doing a network call!") | |
Thread.sleep(1000) // Long running process | |
it.onError(Exception()) // Some error thrown | |
}.retryWhen { errors -> | |
errors.zipWith(Observable.range(1, 3) // Zip error observable with a range one | |
.concatMap { retryCount -> | |
Observable.timer(retryCount.toLong() * 10, TimeUnit.SECONDS) | |
} | |
) | |
}.blockingSubscribeBy( | |
onNext = { println(it) }, | |
onError = { println(it) }, | |
onComplete = { println("Complete") } | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment