Part of why Eyas, the author of this article, recommends using RxJS Observables all the way through in Angular TypeScript code, and only unpacking them at the closest point to where the UI is declared (often using the | async pipe), is because it makes other transformations on an Observable available and convenient. Two such examples include retry and refresh logic.
Etienne once read somewhere that we should always keep our Components as small as possible. It’s then easier to understand and forces us to put reusable logic in Services. But when you need to get data from an API, then you may need to map the data to fit the format you want. We’ll need to take care of all this in our Component once it’s initiated… right?
Have you ever been in need of a centralized system that takes care of your http responses? Every time you work on a big project with a ton of http requests, that problem comes to the surface.
In this article, we will learn how to deal with it, by using an http interceptor and the ngx-toastr plugin to display those messages.