retryWhen let's you do basic retry
with strategy, based on error emissions:
123456789101112131415161718192021222324252627282930313233const {rxObserver} = require('api/v0.3'); const { timer } = require('rxjs'); const { map, tap, retryWhen, delayWhen } = require('rxjs/operators'); const source$ = timer(0, 100).pipe( map(val => { if (val == 1) { throw 'Err'; } return val; }) ); const result$ = source$.pipe( retryWhen(errors => // here Errors are just events errors.pipe( // show error messages thread tap(rxObserver('Error messages')), // will restart with increasing delay delayWhen((_, index) => timer(index * 50)) ) ) ); source$.subscribe(rxObserver('source$')); result$.subscribe(rxObserver('result$')); // a modification of // https://www.learnrxjs.io/operators/error_handling/retrywhen.html
⚠️ Execution time is limited to 1000ms
Check out "Error handling in RxJS" article to get better understanding how not to fail with Observables.