You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.
Matthew Podwysocki edited this page May 7, 2015
·
2 revisions
RxJS Recipes
Error Handling
There are many ways of handling errors in RxJS. This will cover a number of recipes when handling errors:
Incremental retry with retryWhen
Incremental retry with retryWhen
This example will show how you can back off a retry for a number of seconds between tries instead of retrying them all at once.
functionidentity(x){returnx;}Rx.Observable.create(o=>{console.log('subscribing');o.onError(newError('always fails'));}).retryWhen(function(attempts){returnRx.Observable.range(1,3).zip(attempts,identity).flatMap(function(i){console.log('delay retry by '+i+' second(s)');returnRx.Observable.timer(i*1000);});}).subscribe();/*subscribingdelay retry by 1 second(s)subscribingdelay retry by 2 second(s)subscribingdelay retry by 3 second(s)subscribing*/