The problem is that when the Observable notification returned from the callback in retryWhensends a notification complete, which it then propagates as complete, which is not what you want from your description.
error, , take() .
, :
Observable.defer(() => Observable.throw("It broken"))
.retryWhen(err => {
console.log('retry');
let retries = 0;
return err
.delay(1000)
.map(error => {
if (retries++ === 5) {
throw error;
}
return error;
});
})
.catch(err => {
console.log('catch');
return Observable.of(err);
})
.subscribe(data => {
console.log('subscribe');
console.log(data);
});
retries , , . map() try-catch, , , error.