Created
February 8, 2019 12:36
-
-
Save chaosmonster/adda1c0eed467fd6cd760408245ff60e 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
export const onInit = <T extends Constructor>(base: T = class {} as T) => | |
class OnInitSubject extends base implements OnInit, AfterViewInit { | |
private _init = new BehaviorSubject<void>(null); | |
onInit$ = this._init.asObservable(); | |
ngOnInit(): void { | |
this._init.next(); | |
// tslint:disable-next-line:no-unused-expression | |
super['ngOnInit'] && super['ngOnInit'](); | |
} | |
ngAfterViewInit(): void { | |
this._init.complete(); | |
// tslint:disable-next-line:no-unused-expression | |
super['ngAfterViewInit'] && super['ngAfterViewInit'](); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment