Skip to content

Instantly share code, notes, and snippets.

@X-Bird
Created December 30, 2017 11:21
Show Gist options
  • Save X-Bird/77999281d866b91e638cb5a9af74a6fc to your computer and use it in GitHub Desktop.
Save X-Bird/77999281d866b91e638cb5a9af74a6fc to your computer and use it in GitHub Desktop.
Rxjs retryWhen
Rx.Observable.throw(new Error('splut'))
.retryWhen(attempts =>
Rx.Observable.range(1, 3)
.zip(attempts, i => i)
.mergeMap(i => {
console.log('delay retry by ' + i + ' second(s)');
return Rx.Observable.timer(i * 1000);
}),
)
.subscribe();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment