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?
Sometimes it can happen that you assign a value on a service‘s property in your Angular app from a component and, when you try to get that value from a different component, it just returns undefined or the default value in your constructor! How can this be possible, if you just set it? There may … Continue reading Why my Angular service doesn’t return the assigned value?
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!
As of today, deploying an i18n Angular 2 app is not so easy. The documentation is poor and things are still in development. Despite that, after weeks of struggle, I managed to make things work. And so you do now.
When testing a component with service dependencies, the best practice is mocking them, in order to test the component in an isolated environment. In fact, our purpose is testing the component, not the services, that can be trouble, especially if they try to interact with a server.In this article we will see the two methods … Continue reading Testing an Angular Component with Mock Services
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.