Some more RxJS 6 examples in Angular 6. Each example follows the new Angular 6 RxJS 6 coding styles so they are tree-shakable and future-proof.
Error handling – How to catch an error
The “subscribe” method provides an error parameter to catch errors. e.g. myObserverable.subscribe({ error: err => console.error(‘Caught ‘ + err) });.
Try out the example on StackBlitz.
catchError – How to gracefully handle errors
The “catchError” operator gracefully handles errors in an observable sequence. e.g. catchError(err => of(err.message)).
Find out why this is important here.
Try out the example on StackBlitz.
retry – How to retry an observable sequence when an error occurs
The “retry” operator retries an observable sequence a number of times when an error occur.. e.g. retry(2).
Try out the example on StackBlitz.
Other articles in this series
- RxJS 6 examples in Angular 6 – Creating observables
- RxJS 6 examples in Angular 6 – Transformation Operators
- RxJS 6 examples in Angular 6 – Filtering Operators
- RxJS 6 examples in Angular 6 – Conditional Operators
- RxJS 6 examples in Angular 6 – Error Handling Operators
- RxJS 6 examples in Angular 6 – Unsubscribe from Observables