https://www.jianshu.com/p/1e1c7e7cec50
var example = this.service.gettest().pipe(
map((val) => {
console.log(val.toString())
if (parseInt(val.toString()) < 20) {
throw new Error('oops!');
} else {
return val;
}
}),
retryWhen(errors =>
errors.pipe(
tap(val => {
console.log("Retry in 10 sec");
}),
take(attempts),
delay(1000)
))
);
example.subscribe({
next: (val: any) => console.log(val),
error: (val: any) => console.log(val)
});
}