Skip to content

Instantly share code, notes, and snippets.

@btroncone
btroncone / subscription-cleanup.md
Last active April 19, 2022 22:29
Cleaning up subscriptions in Angular

Which do you prefer?

Adding to common sub, calling subscription.unsubscribe() in ngOnDestroy:

export class MyComponent {
  private _subscription: Subscription;
  
  ngOnInit() {
    this._subscription = myObservable