'Unsubscribe from subscription in Angular component(subscription gets and proceeds response)
I'm very new in Angular and have a question. I have a service where http methods are called and component where I have subscription on methods results(procced result, open modal, off loading banner and pass it to component). Should I unsubscribe from these subscriptions in onNgDestroy method?(also I have post and put methods in service and subscription on them in component) thanks in advance! Method from component:
openEditUserModal(id) {
this.isLoading = true;
this.rulesManagementService.findUser(id).subscribe(response => {
if (response) {
this.isModalOpen = true;
this.user = user;
this.isLoading = false;
}
}, error => this.handleError(error));
}
Method in service:
findUser(id: number): Observable<User> {
return this.httpClient.get(url).pipe(
catchError(handleError),
map(value => new User().deserialize(value))
);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
