Created
December 30, 2017 11:21
-
-
Save X-Bird/77999281d866b91e638cb5a9af74a6fc to your computer and use it in GitHub Desktop.
Rxjs retryWhen
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
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