RxJS study - retry promise
const { from, of } = require("rxjs")
const { switchMap, retry }= require("rxjs/operators")
function getSearchResults(url) {
return new Promise((resolve, reject) => {
console.log('do again')
reject("Reject")
})
}
of("http://foo.com").pipe(
switchMap(url => from(getSearchResults(url))),
retry(3)
)
.subscribe({
next: val => console.log(val),
error: val => console.log(`Get error ${val}`)
})
no comments