chore(LifecycleEvent): change to PascalCase / rename

BREAKING CHANGE

Closes #3863

- LifecycleEvent.onInit => LifecycleEvent.OnInit
- LifecycleEvent.onDestroy => LifecycleEvent.OnDestroy
- LifecycleEvent.onChange => LifecycleEvent.OnChanges
- LifecycleEvent.onCheck => LifecycleEvent.DoCheck
- LifecycleEvent.onAllChangesDone => LifecycleEvent.AfterContentChecked
- OnCheck.onCheck() => DoCheck.doCheck()
- OnChange.onChange() => OnChanges.onChanges()
- OnAllChangesDone.onAllChangesDone() => AfterContentChecked.afterContentChecked

Closes #3851
This commit is contained in:
Misko Hevery
2015-08-27 21:19:56 -07:00
parent ac3f5106e4
commit 551d9a1688
64 changed files with 492 additions and 487 deletions

View File

@ -13,15 +13,15 @@ bool hasLifecycleHook(LifecycleEvent e, type, DirectiveMetadata annotation) {
final List interfaces = reflector.interfaces(type);
var interface;
if (e == LifecycleEvent.onChange) {
interface = OnChange;
} else if (e == LifecycleEvent.onDestroy) {
if (e == LifecycleEvent.OnChanges) {
interface = OnChanges;
} else if (e == LifecycleEvent.OnDestroy) {
interface = OnDestroy;
} else if (e == LifecycleEvent.onAllChangesDone) {
interface = OnAllChangesDone;
} else if (e == LifecycleEvent.onCheck) {
interface = OnCheck;
} else if (e == LifecycleEvent.onInit) {
} else if (e == LifecycleEvent.AfterContentChecked) {
interface = AfterContentChecked;
} else if (e == LifecycleEvent.DoCheck) {
interface = DoCheck;
} else if (e == LifecycleEvent.OnInit) {
interface = OnInit;
}

View File

@ -8,15 +8,15 @@ export function hasLifecycleHook(e: LifecycleEvent, type, annotation: DirectiveM
if (!(type instanceof Type)) return false;
var proto = (<any>type).prototype;
switch (e) {
case LifecycleEvent.onAllChangesDone:
return !!proto.onAllChangesDone;
case LifecycleEvent.onChange:
return !!proto.onChange;
case LifecycleEvent.onCheck:
return !!proto.onCheck;
case LifecycleEvent.onDestroy:
case LifecycleEvent.AfterContentChecked:
return !!proto.afterContentChecked;
case LifecycleEvent.OnChanges:
return !!proto.onChanges;
case LifecycleEvent.DoCheck:
return !!proto.doCheck;
case LifecycleEvent.OnDestroy:
return !!proto.onDestroy;
case LifecycleEvent.onInit:
case LifecycleEvent.OnInit:
return !!proto.onInit;
default:
return false;

View File

@ -204,9 +204,9 @@ export class DirectiveBinding extends ResolvedBinding {
get callOnDestroy(): boolean { return this.metadata.callOnDestroy; }
get callOnChange(): boolean { return this.metadata.callOnChange; }
get callOnChanges(): boolean { return this.metadata.callOnChanges; }
get callOnAllChangesDone(): boolean { return this.metadata.callOnAllChangesDone; }
get callAfterContentChecked(): boolean { return this.metadata.callAfterContentChecked; }
get displayName(): string { return this.key.displayName; }
@ -238,11 +238,12 @@ export class DirectiveBinding extends ResolvedBinding {
properties: ann.properties,
readAttributes: DirectiveBinding._readAttributes(deps),
callOnDestroy: hasLifecycleHook(LifecycleEvent.onDestroy, rb.key.token, ann),
callOnChange: hasLifecycleHook(LifecycleEvent.onChange, rb.key.token, ann),
callOnCheck: hasLifecycleHook(LifecycleEvent.onCheck, rb.key.token, ann),
callOnInit: hasLifecycleHook(LifecycleEvent.onInit, rb.key.token, ann),
callOnAllChangesDone: hasLifecycleHook(LifecycleEvent.onAllChangesDone, rb.key.token, ann),
callOnDestroy: hasLifecycleHook(LifecycleEvent.OnDestroy, rb.key.token, ann),
callOnChanges: hasLifecycleHook(LifecycleEvent.OnChanges, rb.key.token, ann),
callDoCheck: hasLifecycleHook(LifecycleEvent.DoCheck, rb.key.token, ann),
callOnInit: hasLifecycleHook(LifecycleEvent.OnInit, rb.key.token, ann),
callAfterContentChecked:
hasLifecycleHook(LifecycleEvent.AfterContentChecked, rb.key.token, ann),
changeDetection: ann instanceof ComponentMetadata ? ann.changeDetection : null,
@ -431,7 +432,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
this._strategy.dehydrate();
}
onAllChangesDone(): void {
afterContentChecked(): void {
if (isPresent(this._query0) && this._query0.originator === this) {
this._query0.list.fireCallbacks();
}

View File

@ -6,32 +6,32 @@ import {global} from 'angular2/src/core/facade/lang';
// https://github.com/systemjs/systemjs/issues/487 gets closed.
var __ignore_me = global;
/**
* Defines lifecycle method {@link annotations/LifeCycleEvent#onChange `LifeCycleEvent.onChange`}
* Defines lifecycle method {@link metadata/LifeCycleEvent#OnChanges `LifeCycleEvent.OnChanges`}
* called after all of component's bound properties are updated.
*/
export interface OnChange { onChange(changes: StringMap<string, any>): void; }
export interface OnChanges { onChanges(changes: StringMap<string, any>): void; }
/**
* Defines lifecycle method {@link annotations/LifeCycleEvent#onDestroy `LifeCycleEvent.onDestroy`}
* called when a directive is being destroyed.
*/
export interface OnDestroy { onDestroy(): void; }
/**
* Defines lifecycle method {@link annotations/LifeCycleEvent#onCheck `LifeCycleEvent.onCheck`}
* called when a directive is being checked.
*/
export interface OnCheck { onCheck(): void; }
/**
* Defines lifecycle method {@link annotations/LifeCycleEvent#onInit `LifeCycleEvent.onInit`}
* Defines lifecycle method {@link metadata/LifeCycleEvent#OnInit `LifeCycleEvent.OnInit`}
* called when a directive is being checked the first time.
*/
export interface OnInit { onInit(): void; }
/**
* Defines lifecycle method
* {@link annotations/LifeCycleEvent#onAllChangesDone `LifeCycleEvent.onAllChangesDone`}
* called when the bindings of all its children have been changed.
* Defines lifecycle method {@link metadata/LifeCycleEvent#DoCheck `LifeCycleEvent.DoCheck`}
* called when a directive is being checked.
*/
export interface OnAllChangesDone { onAllChangesDone(): void; }
export interface DoCheck { doCheck(): boolean; }
/**
* Defines lifecycle method {@link metadata/LifeCycleEvent#OnDestroy `LifeCycleEvent.OnDestroy`}
* called when a directive is being destroyed.
*/
export interface OnDestroy { onDestroy(): void; }
/**
* Defines lifecycle method
* {@link metadata/LifeCycleEvent#AfterContentChecked `LifeCycleEvent.afterContentChecked`}
* called when the bindings of all its view children have been changed.
*/
export interface AfterContentChecked { afterContentChecked(): void; }

View File

@ -150,14 +150,14 @@ export class BindingRecordsCreator {
BindingRecord.createForDirective(astWithSource, propertyName, setter, directiveRecord));
});
if (directiveRecord.callOnChange) {
bindings.push(BindingRecord.createDirectiveOnChange(directiveRecord));
if (directiveRecord.callOnChanges) {
bindings.push(BindingRecord.createDirectiveOnChanges(directiveRecord));
}
if (directiveRecord.callOnInit) {
bindings.push(BindingRecord.createDirectiveOnInit(directiveRecord));
}
if (directiveRecord.callOnCheck) {
bindings.push(BindingRecord.createDirectiveOnCheck(directiveRecord));
if (directiveRecord.callDoCheck) {
bindings.push(BindingRecord.createDirectiveDoCheck(directiveRecord));
}
}
@ -191,9 +191,9 @@ export class BindingRecordsCreator {
this._directiveRecordsMap.set(
id, new DirectiveRecord({
directiveIndex: new DirectiveIndex(boundElementIndex, directiveIndex),
callOnAllChangesDone: directiveMetadata.callOnAllChangesDone,
callOnChange: directiveMetadata.callOnChange,
callOnCheck: directiveMetadata.callOnCheck,
callAfterContentChecked: directiveMetadata.callAfterContentChecked,
callOnChanges: directiveMetadata.callOnChanges,
callDoCheck: directiveMetadata.callDoCheck,
callOnInit: directiveMetadata.callOnInit,
changeDetection: directiveMetadata.changeDetection
}));

View File

@ -204,11 +204,11 @@ export class AppView implements ChangeDispatcher, RenderEventDispatcher {
}
}
notifyOnAllChangesDone(): void {
notifyAfterContentChecked(): void {
var eiCount = this.proto.elementBinders.length;
var ei = this.elementInjectors;
for (var i = eiCount - 1; i >= 0; i--) {
if (isPresent(ei[i + this.elementOffset])) ei[i + this.elementOffset].onAllChangesDone();
if (isPresent(ei[i + this.elementOffset])) ei[i + this.elementOffset].afterContentChecked();
}
}