What we most likely want is to combine the delay between retry attempts with being able to specify how many times we want to retry the stream. Let's have a look at how we can accomplish that:
// error-handling/error-retry-advanced.jsconst Rx = require("rxjs/Rx");let ajaxStream$ = Rx.Observable.ajax("UK1.json") .do(r => console.log("emitted")) .map(r => r.response) .retryWhen(err => { return err .delay(3000) .take(3);});
The interesting part here is that we use the operator .take(). We specify the number of emitted values we want from this inner Observable. We have now accomplished a nice approach in which we are able to control the number of retries and the delay between retries. There is an aspect to this that we haven't tried, ...