Created
June 5, 2017 06:55
-
-
Save pgiemza/1b81188e56ff24c977e605f9feb1d2f2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/Subject'; | |
export abstract class BaseComponent implements OnDestroy { | |
protected destroyed$: Subject<boolean> = new Subject(); | |
protected constructor() {} | |
ngOnDestroy(): void { | |
this.destroyed$.next(true); | |
this.destroyed$.complete(); | |
} | |
} |
This should have issues with AOT compilation, see here angular/angular#19145
Clever, implemented with success. Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I really like this approach. Below is a stackblitz showing this in action.
https://stackblitz.com/edit/angular-zjppzp