2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2017-02-17 15:55:55 -05:00
|
|
|
import {ɵLifecycleHooks, ɵreflector} from '@angular/core';
|
2016-04-28 20:50:03 -04:00
|
|
|
|
2015-08-31 21:32:32 -04:00
|
|
|
|
2017-02-17 15:55:55 -05:00
|
|
|
export function hasLifecycleHook(hook: ɵLifecycleHooks, token: any): boolean {
|
|
|
|
return ɵreflector.hasLifecycleHook(token, getHookName(hook));
|
2016-10-11 21:42:00 -04:00
|
|
|
}
|
|
|
|
|
2017-02-17 15:55:55 -05:00
|
|
|
function getHookName(hook: ɵLifecycleHooks): string {
|
2016-10-11 21:42:00 -04:00
|
|
|
switch (hook) {
|
2017-02-17 15:55:55 -05:00
|
|
|
case ɵLifecycleHooks.OnInit:
|
2016-10-11 21:42:00 -04:00
|
|
|
return 'ngOnInit';
|
2017-02-17 15:55:55 -05:00
|
|
|
case ɵLifecycleHooks.OnDestroy:
|
2016-10-11 21:42:00 -04:00
|
|
|
return 'ngOnDestroy';
|
2017-02-17 15:55:55 -05:00
|
|
|
case ɵLifecycleHooks.DoCheck:
|
2016-10-11 21:42:00 -04:00
|
|
|
return 'ngDoCheck';
|
2017-02-17 15:55:55 -05:00
|
|
|
case ɵLifecycleHooks.OnChanges:
|
2016-10-11 21:42:00 -04:00
|
|
|
return 'ngOnChanges';
|
2017-02-17 15:55:55 -05:00
|
|
|
case ɵLifecycleHooks.AfterContentInit:
|
2016-10-11 21:42:00 -04:00
|
|
|
return 'ngAfterContentInit';
|
2017-02-17 15:55:55 -05:00
|
|
|
case ɵLifecycleHooks.AfterContentChecked:
|
2016-10-11 21:42:00 -04:00
|
|
|
return 'ngAfterContentChecked';
|
2017-02-17 15:55:55 -05:00
|
|
|
case ɵLifecycleHooks.AfterViewInit:
|
2016-10-11 21:42:00 -04:00
|
|
|
return 'ngAfterViewInit';
|
2017-02-17 15:55:55 -05:00
|
|
|
case ɵLifecycleHooks.AfterViewChecked:
|
2016-10-11 21:42:00 -04:00
|
|
|
return 'ngAfterViewChecked';
|
|
|
|
}
|
2017-02-17 15:55:55 -05:00
|
|
|
}
|