refactor(ivy): flatten hooks and collapse LView hook properties (#21650)

PR Close #21650
This commit is contained in:
Kara Erickson
2018-01-23 18:39:09 -08:00
committed by Misko Hevery
parent 33b338120c
commit 3e03dbe576
11 changed files with 113 additions and 129 deletions

View File

@ -71,14 +71,16 @@ export interface DirectiveDef<T> {
* Refreshes host bindings on the associated directive. Also calls lifecycle hooks
* like ngOnInit and ngDoCheck, if they are defined on the directive.
*/
// Note: This call must be separate from r() because hooks like ngOnInit need to
// be called breadth-first across a view before processing onInits in children
// (for backwards compatibility). Child template processing thus needs to be
// delayed until all inputs and host bindings in a view have been checked.
h(directiveIndex: number, elementIndex: number): void;
/* A map of the lifecycle hooks defined on this directive (key: name, value: fn) */
lifecycleHooks: LifecycleHooksMap;
/* The following are lifecycle hooks for this component */
onInit: (() => void)|null;
doCheck: (() => void)|null;
afterContentInit: (() => void)|null;
afterContentChecked: (() => void)|null;
afterViewInit: (() => void)|null;
afterViewChecked: (() => void)|null;
onDestroy: (() => void)|null;
}
export interface ComponentDef<T> extends DirectiveDef<T> {
@ -104,17 +106,6 @@ export interface ComponentDef<T> extends DirectiveDef<T> {
readonly rendererType: RendererType2|null;
}
/* A map of the lifecycle hooks defined on a directive (key: name, value: fn) */
export interface LifecycleHooksMap {
onInit: () => void | null;
doCheck: () => void | null;
afterContentInit: () => void | null;
afterContentChecked: () => void | null;
afterViewInit: () => void | null;
afterViewChecked: () => void | null;
onDestroy: () => void | null;
}
export interface DirectiveDefArgs<T> {
type: Type<T>;
factory: () => T;