Skip to content

Instantly share code, notes, and snippets.

@kaplan81
Last active February 2, 2020 21:37
Show Gist options
  • Save kaplan81/b352fb5b9fd57d5c3e8b7e3be2a4d0a5 to your computer and use it in GitHub Desktop.
Save kaplan81/b352fb5b9fd57d5c3e8b7e3be2a4d0a5 to your computer and use it in GitHub Desktop.
import { OnDestroy } from '@angular/core';
import { Subject } from 'rxjs';
export abstract class SubscribedContainer implements OnDestroy {
destroyed$ = new Subject<void>();
/**
* DO NOT this.destroyed$.complete();
* It is not necessary:
* https://stackoverflow.com/questions/44289859/do-i-need-to-complete-a-subject-for-it-to-be-garbage-collected
*/
ngOnDestroy(): void {
this.destroyed$.next();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment