Skip to content

docs: clearly explain if/when we need to unsubscribe from HttpClient calls #46542

@digeomel

Description

@digeomel

Description

Hello, I've been going through the documentation of the HttpClient service (https://angular.io/guide/http) trying to find any mention of whether it is necessary to unsubscribe from the generated observables or not, and the only mention I could find was about using the AsyncPipe, which is irrelevant (because we don't have to or might not want to use it).

So, I think the documentation should clarify when (if ever) we need to unsubscribe from calls.

Update:
Perhaps I should clarify a bit more. This article:
https://medium.com/angular-in-depth/why-you-have-to-unsubscribe-from-observable-92502d5639d0
explains very well the reasons why we should unsubscribe from all HttpClient observables always.
Personally, I've struggled to convince my team to do it, because their usual answer is that HttpClient will do it automatically and of course very few people bother to read beyond the official documentation which doesn't mention anything about unsubscribing.
I have been doing it for a long time with Net Basal's excellent ng-neat/until-destroy library, but I feel that this is such a core concept of any real-life Angular app that it should be clearly documented.

Metadata

Metadata

Assignees

Labels

P2The issue is important to a large percentage of users, with a workaroundarea: common/httpIssues related to HTTP and HTTP Clientopen for contributionsAn issue that is suitable for a community contributor (based on its complexity/scope).

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions