Last active
April 26, 2019 15:20
-
-
Save kievsash/614f8c7fbcbe644b525000d1fe8e2a45 to your computer and use it in GitHub Desktop.
retry+repeat
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
//js | |
let Rx = window['rxjs']; | |
const {defer} = Rx; | |
const {take, repeat} = Rx.operators; | |
const {ajax} = Rx.ajax; | |
console.clear(); | |
let counter=0; | |
const getData = () => defer(() => ajax('http://localhost:4001/list-data?page='+counter++)) | |
.pipe(retry(2), repeat(2)) | |
let repetableObservable = getData(); | |
repetableObservable.subscribe( | |
(data) => console.log(data.response), | |
console.warn | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment