You have probably heard many times that it’s a good practice to unsubscribe from an Observable after you subscribe to it in your Angular application. But is it always the case? Do you really need to do it?
What happens if two different components call the same service which makes an HTTP call to an API? You will have two duplicated calls! Is it possible to share the first response with all subscribers to prevent duplicate HTTP requests? Yes, it is! Let’s see how.
Whichever authentication method you use for logging in users in your Angular application, there will always be a problem to solve: starting your app and initialize views and components only after the user info is fully loaded. Let’s see how to do it!
Observables, Subjects and EventEmitters are amazing, I love them. But they have a common problem: what if you subscribe to one of them when the event has been already emitted? You would lose it!
RxJS Observables, compared to the old Promises in Angular 1, seem to be more complicated to understand, but they are far more flexible. Let’s see how we can combine and chain them, in order to merge multiple Http streams of data and get what we need.