Created
October 5, 2015 20:25
-
-
Save djensen47/a0612c2cd090c8d4372a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// from: http://www.slideshare.net/Couchbase/reactive-programmingrxjavaefficientdata-benchristensenmichaelnitschinger/75 | |
Observable | |
.defer(() -> bucket.get("id")) | |
.retryWhen(attempts -> attempts | |
.zipWith(Observable.range(1,3), (n, i) -> i) | |
.flatMap(i -> { | |
System.out.println("Delaying retry by " + i + " second(s)"); | |
return Observable.timer(i, TimeUnit.SECONDS) | |
}) | |
) | |
.toBlocking() | |
.forEach(System.out::println); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment