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
|
|
|
|
*/
|
|
|
|
|
2016-08-10 21:21:28 -04:00
|
|
|
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnDestroy, OnInit, Type} from '@angular/core';
|
2016-08-02 18:53:34 -04:00
|
|
|
|
2016-07-21 16:56:58 -04:00
|
|
|
import {MapWrapper} from './facade/collection';
|
2016-08-30 21:07:40 -04:00
|
|
|
import {LifecycleHooks, reflector} from './private_import_core';
|
2016-04-28 20:50:03 -04:00
|
|
|
|
2016-08-10 21:21:28 -04:00
|
|
|
const LIFECYCLE_INTERFACES: Map<any, Type<any>> = MapWrapper.createFromPairs([
|
2016-05-04 13:00:59 -04:00
|
|
|
[LifecycleHooks.OnInit, OnInit],
|
|
|
|
[LifecycleHooks.OnDestroy, OnDestroy],
|
|
|
|
[LifecycleHooks.DoCheck, DoCheck],
|
|
|
|
[LifecycleHooks.OnChanges, OnChanges],
|
|
|
|
[LifecycleHooks.AfterContentInit, AfterContentInit],
|
|
|
|
[LifecycleHooks.AfterContentChecked, AfterContentChecked],
|
|
|
|
[LifecycleHooks.AfterViewInit, AfterViewInit],
|
|
|
|
[LifecycleHooks.AfterViewChecked, AfterViewChecked],
|
|
|
|
]);
|
2015-05-27 11:08:14 -04:00
|
|
|
|
2016-05-04 13:00:59 -04:00
|
|
|
const LIFECYCLE_PROPS: Map<any, string> = MapWrapper.createFromPairs([
|
|
|
|
[LifecycleHooks.OnInit, 'ngOnInit'],
|
|
|
|
[LifecycleHooks.OnDestroy, 'ngOnDestroy'],
|
|
|
|
[LifecycleHooks.DoCheck, 'ngDoCheck'],
|
|
|
|
[LifecycleHooks.OnChanges, 'ngOnChanges'],
|
|
|
|
[LifecycleHooks.AfterContentInit, 'ngAfterContentInit'],
|
|
|
|
[LifecycleHooks.AfterContentChecked, 'ngAfterContentChecked'],
|
|
|
|
[LifecycleHooks.AfterViewInit, 'ngAfterViewInit'],
|
|
|
|
[LifecycleHooks.AfterViewChecked, 'ngAfterViewChecked'],
|
|
|
|
]);
|
2015-08-31 21:32:32 -04:00
|
|
|
|
2016-06-28 14:35:59 -04:00
|
|
|
export function hasLifecycleHook(hook: LifecycleHooks, token: any): boolean {
|
2016-05-04 13:00:59 -04:00
|
|
|
var lcInterface = LIFECYCLE_INTERFACES.get(hook);
|
|
|
|
var lcProp = LIFECYCLE_PROPS.get(hook);
|
|
|
|
return reflector.hasLifecycleHook(token, lcInterface, lcProp);
|
2015-07-04 09:04:50 -04:00
|
|
|
}
|