Member-only story
Unsubscribe in Unnecessary in httpClient Angular
What is unsubscribe? — Realtime analogy
Say if you want subscribed to Newspaper subscription, you will start receiving newspaper whenever it is distributed based on your plan and frequency of publication.
There are two ways that you will not receive the Newspaper further
- The Distributor stops it for whatever reason could be (subscription not renewed, Newspaper company stopped their business)
- You stopped the subscription (UNSUBSCRIBE)
So when you are opt for receiving something and when you want to opted out from receiving something, it is unsubscribing.
Say for example you are paying a one time fee and receiving a Newspaper for one time. Why we need to unsubscribe, when you are no longer going to receive the Newspaper
Same is the case for unsubscribing a httpClient or any other AJAX calls with rxjs, when we make a http call, we either get success response or failure response and in either case it will be completed, we will no longer receive any events from this.
So there is no point in unsubscribing to this subscriptions when it has zero effect.
If either an Error or Complete notification is delivered…