Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Created May 6, 2015 16:52
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattpodwysocki/1c21ae87be75466c573f to your computer and use it in GitHub Desktop.
Save mattpodwysocki/1c21ae87be75466c573f to your computer and use it in GitHub Desktop.
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