Skip to content

Instantly share code, notes, and snippets.

@kievsash
Last active April 26, 2019 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kievsash/614f8c7fbcbe644b525000d1fe8e2a45 to your computer and use it in GitHub Desktop.
Save kievsash/614f8c7fbcbe644b525000d1fe8e2a45 to your computer and use it in GitHub Desktop.
retry+repeat
//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