Welcome to %s forums

<No. 1 Community for developers, by developers/>

Login Register

How to unsubscribe Observer?

Get support on Angular & Typescript related technology.
Post Reply
anono

How to unsubscribe Observer?

Post by anono » Thu Aug 22, 2019 9:04 pm

How to unsubscribe Observer?

admin
Site Admin
Posts: 45

Post by admin » Thu Aug 22, 2019 9:12 pm

Observable cannot be unsubscribed, subscription can be unsubscribed:
For example:
subscription value in a component like

Code: Select all

sub: Subscription;
And your subscribe will be

Code: Select all

this.sub = this.listner.changes.subscribe((res: anyData) => {});
And onDestroy Will be

Code: Select all

ngOnDestroy() {
   this.sub.unsubsribe();
 }
What are Observables in Angular?
Observables are lazy collections of multiple values over time.

For more info refer official documentation https://angular.io/guide/observables-in-angular

Post Reply