Last active
February 2, 2020 21:37
-
-
Save kaplan81/b352fb5b9fd57d5c3e8b7e3be2a4d0a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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