Created
May 6, 2015 16:52
-
-
Save mattpodwysocki/1c21ae87be75466c573f 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
Rx.Observable.create(o => { | |
console.log("subscribing"); | |
o.onError(new Error("always fails")); | |
}).retryWhen(attempts -> { | |
return attempts.zip(Rx.Observable.range(1, 3), (n, i) => i).flatMap(i => { | |
console.log("delay retry by " + i + " second(s)"); | |
return Rx.Observable.timer(i * 1000); | |
}); | |
}).subscribe(); | |
/* | |
subscribing | |
delay retry by 1 second(s) | |
subscribing | |
delay retry by 2 second(s) | |
subscribing | |
delay retry by 3 second(s) | |
subscribing | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment