Skip to content

Commit 551d9a1

Browse files
committed
chore(LifecycleEvent): change to PascalCase / rename
BREAKING CHANGE Closes angular#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 angular#3851
1 parent ac3f510 commit 551d9a1

File tree

64 files changed

+486
-481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+486
-481
lines changed

modules/angular2/metadata.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ export {
3838
} from './src/core/metadata';
3939

4040
export {
41-
OnAllChangesDone,
42-
OnChange,
41+
AfterContentChecked,
42+
OnChanges,
4343
OnDestroy,
4444
OnInit,
45-
OnCheck
45+
DoCheck
4646
} from './src/core/compiler/interfaces';
4747

4848
export {Class, ClassDefinition, TypeDecorator} from './src/core/util/decorators';

modules/angular2/src/core/change_detection/abstract_change_detector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
8484
var s = _scope_check(this.id, throwOnChange);
8585
this.detectChangesInRecords(throwOnChange);
8686
this._detectChangesInLightDomChildren(throwOnChange);
87-
if (throwOnChange === false) this.callOnAllChangesDone();
87+
if (throwOnChange === false) this.callAfterContentChecked();
8888
this._detectChangesInShadowDomChildren(throwOnChange);
8989
if (this.mode === ChangeDetectionStrategy.CheckOnce)
9090
this.mode = ChangeDetectionStrategy.Checked;
@@ -156,7 +156,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
156156

157157
hydrated(): boolean { return this.context !== null; }
158158

159-
callOnAllChangesDone(): void { this.dispatcher.notifyOnAllChangesDone(); }
159+
callAfterContentChecked(): void { this.dispatcher.notifyAfterContentChecked(); }
160160

161161
_detectChangesInLightDomChildren(throwOnChange: boolean): void {
162162
var c = this.lightDomChildren;

modules/angular2/src/core/change_detection/binding_record.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,26 @@ export class BindingRecord {
3939

4040
isDirectiveLifecycle(): boolean { return this.mode === DIRECTIVE_LIFECYCLE; }
4141

42-
callOnChange(): boolean {
43-
return isPresent(this.directiveRecord) && this.directiveRecord.callOnChange;
42+
callOnChanges(): boolean {
43+
return isPresent(this.directiveRecord) && this.directiveRecord.callOnChanges;
4444
}
4545

4646
isDefaultChangeDetection(): boolean {
4747
return isBlank(this.directiveRecord) || this.directiveRecord.isDefaultChangeDetection();
4848
}
4949

5050

51-
static createDirectiveOnCheck(directiveRecord: DirectiveRecord): BindingRecord {
52-
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "onCheck", directiveRecord);
51+
static createDirectiveDoCheck(directiveRecord: DirectiveRecord): BindingRecord {
52+
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "DoCheck", directiveRecord);
5353
}
5454

5555
static createDirectiveOnInit(directiveRecord: DirectiveRecord): BindingRecord {
56-
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "onInit", directiveRecord);
56+
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "OnInit", directiveRecord);
5757
}
5858

59-
static createDirectiveOnChange(directiveRecord: DirectiveRecord): BindingRecord {
60-
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "onChange", directiveRecord);
59+
static createDirectiveOnChanges(directiveRecord: DirectiveRecord): BindingRecord {
60+
return new BindingRecord(DIRECTIVE_LIFECYCLE, null, 0, null, null, "OnChanges",
61+
directiveRecord);
6162
}
6263

6364

modules/angular2/src/core/change_detection/change_detection_jit_generator.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class ChangeDetectorJITGenerator {
7171
7272
${this._genCheckNoChanges()}
7373
74-
${this._maybeGenCallOnAllChangesDone()}
74+
${this._maybeGenCallAfterContentChecked()}
7575
7676
${this._maybeGenHydrateDirectives()}
7777
@@ -172,23 +172,23 @@ export class ChangeDetectorJITGenerator {
172172
}`;
173173
}
174174

175-
_maybeGenCallOnAllChangesDone(): string {
175+
_maybeGenCallAfterContentChecked(): string {
176176
var notifications = [];
177177
var dirs = this.directiveRecords;
178178

179179
// NOTE(kegluneq): Order is important!
180180
for (var i = dirs.length - 1; i >= 0; --i) {
181181
var dir = dirs[i];
182-
if (dir.callOnAllChangesDone) {
182+
if (dir.callAfterContentChecked) {
183183
notifications.push(
184-
`${this._names.getDirectiveName(dir.directiveIndex)}.onAllChangesDone();`);
184+
`${this._names.getDirectiveName(dir.directiveIndex)}.afterContentChecked();`);
185185
}
186186
}
187187
if (notifications.length > 0) {
188188
var directiveNotifications = notifications.join("\n");
189189
return `
190-
${this._typeName}.prototype.callOnAllChangesDone = function() {
191-
${ABSTRACT_CHANGE_DETECTOR}.prototype.callOnAllChangesDone.call(this);
190+
${this._typeName}.prototype.callAfterContentChecked = function() {
191+
${ABSTRACT_CHANGE_DETECTOR}.prototype.callAfterContentChecked.call(this);
192192
${directiveNotifications}
193193
}
194194
`;
@@ -214,11 +214,11 @@ export class ChangeDetectorJITGenerator {
214214
}
215215

216216
_genDirectiveLifecycle(r: ProtoRecord): string {
217-
if (r.name === "onCheck") {
217+
if (r.name === "DoCheck") {
218218
return this._genOnCheck(r);
219-
} else if (r.name === "onInit") {
219+
} else if (r.name === "OnInit") {
220220
return this._genOnInit(r);
221-
} else if (r.name === "onChange") {
221+
} else if (r.name === "OnChanges") {
222222
return this._genOnChange(r);
223223
} else {
224224
throw new BaseException(`Unknown lifecycle event '${r.name}'`);
@@ -337,7 +337,7 @@ export class ChangeDetectorJITGenerator {
337337
_genAddToChanges(r: ProtoRecord): string {
338338
var newValue = this._names.getLocalName(r.selfIndex);
339339
var oldValue = this._names.getFieldName(r.selfIndex);
340-
if (!r.bindingRecord.callOnChange()) return "";
340+
if (!r.bindingRecord.callOnChanges()) return "";
341341
return `${CHANGES_LOCAL} = this.addChange(${CHANGES_LOCAL}, ${oldValue}, ${newValue});`;
342342
}
343343

@@ -360,7 +360,7 @@ export class ChangeDetectorJITGenerator {
360360

361361
_genOnCheck(r: ProtoRecord): string {
362362
var br = r.bindingRecord;
363-
return `if (!throwOnChange) ${this._names.getDirectiveName(br.directiveRecord.directiveIndex)}.onCheck();`;
363+
return `if (!throwOnChange) ${this._names.getDirectiveName(br.directiveRecord.directiveIndex)}.doCheck();`;
364364
}
365365

366366
_genOnInit(r: ProtoRecord): string {
@@ -370,7 +370,7 @@ export class ChangeDetectorJITGenerator {
370370

371371
_genOnChange(r: ProtoRecord): string {
372372
var br = r.bindingRecord;
373-
return `if (!throwOnChange && ${CHANGES_LOCAL}) ${this._names.getDirectiveName(br.directiveRecord.directiveIndex)}.onChange(${CHANGES_LOCAL});`;
373+
return `if (!throwOnChange && ${CHANGES_LOCAL}) ${this._names.getDirectiveName(br.directiveRecord.directiveIndex)}.onChanges(${CHANGES_LOCAL});`;
374374
}
375375

376376
_genNotifyOnPushDetectors(r: ProtoRecord): string {

modules/angular2/src/core/change_detection/directive_record.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ export class DirectiveIndex {
99

1010
export class DirectiveRecord {
1111
directiveIndex: DirectiveIndex;
12-
callOnAllChangesDone: boolean;
13-
callOnChange: boolean;
14-
callOnCheck: boolean;
12+
callAfterContentChecked: boolean;
13+
callOnChanges: boolean;
14+
callDoCheck: boolean;
1515
callOnInit: boolean;
1616
changeDetection: ChangeDetectionStrategy;
1717

18-
constructor({directiveIndex, callOnAllChangesDone, callOnChange, callOnCheck, callOnInit,
18+
constructor({directiveIndex, callAfterContentChecked, callOnChanges, callDoCheck, callOnInit,
1919
changeDetection}: {
2020
directiveIndex?: DirectiveIndex,
21-
callOnAllChangesDone?: boolean,
22-
callOnChange?: boolean,
23-
callOnCheck?: boolean,
21+
callAfterContentChecked?: boolean,
22+
callOnChanges?: boolean,
23+
callDoCheck?: boolean,
2424
callOnInit?: boolean,
2525
changeDetection?: ChangeDetectionStrategy
2626
} = {}) {
2727
this.directiveIndex = directiveIndex;
28-
this.callOnAllChangesDone = normalizeBool(callOnAllChangesDone);
29-
this.callOnChange = normalizeBool(callOnChange);
30-
this.callOnCheck = normalizeBool(callOnCheck);
28+
this.callAfterContentChecked = normalizeBool(callAfterContentChecked);
29+
this.callOnChanges = normalizeBool(callOnChanges);
30+
this.callDoCheck = normalizeBool(callDoCheck);
3131
this.callOnInit = normalizeBool(callOnInit);
3232
this.changeDetection = changeDetection;
3333
}

modules/angular2/src/core/change_detection/dynamic_change_detector.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
133133
}
134134

135135
if (proto.isLifeCycleRecord()) {
136-
if (proto.name === "onCheck" && !throwOnChange) {
137-
this._getDirectiveFor(directiveRecord.directiveIndex).onCheck();
138-
} else if (proto.name === "onInit" && !throwOnChange && !this.alreadyChecked) {
136+
if (proto.name === "DoCheck" && !throwOnChange) {
137+
this._getDirectiveFor(directiveRecord.directiveIndex).doCheck();
138+
} else if (proto.name === "OnInit" && !throwOnChange && !this.alreadyChecked) {
139139
this._getDirectiveFor(directiveRecord.directiveIndex).onInit();
140-
} else if (proto.name === "onChange" && isPresent(changes) && !throwOnChange) {
141-
this._getDirectiveFor(directiveRecord.directiveIndex).onChange(changes);
140+
} else if (proto.name === "OnChanges" && isPresent(changes) && !throwOnChange) {
141+
this._getDirectiveFor(directiveRecord.directiveIndex).onChanges(changes);
142142
}
143143

144144
} else {
@@ -168,13 +168,13 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
168168
return isBlank(prev) || prev.bindingRecord !== r.bindingRecord;
169169
}
170170

171-
callOnAllChangesDone() {
172-
super.callOnAllChangesDone();
171+
callAfterContentChecked() {
172+
super.callAfterContentChecked();
173173
var dirs = this.directiveRecords;
174174
for (var i = dirs.length - 1; i >= 0; --i) {
175175
var dir = dirs[i];
176-
if (dir.callOnAllChangesDone) {
177-
this._getDirectiveFor(dir.directiveIndex).onAllChangesDone();
176+
if (dir.callAfterContentChecked) {
177+
this._getDirectiveFor(dir.directiveIndex).afterContentChecked();
178178
}
179179
}
180180
}
@@ -193,7 +193,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
193193
}
194194

195195
_addChange(bindingRecord: BindingRecord, change, changes) {
196-
if (bindingRecord.callOnChange()) {
196+
if (bindingRecord.callOnChanges()) {
197197
return super.addChange(changes, change.previousValue, change.currentValue);
198198
} else {
199199
return changes;

modules/angular2/src/core/change_detection/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export interface ChangeDispatcher {
5151
getDebugContext(elementIndex: number, directiveIndex: DirectiveIndex): DebugContext;
5252
notifyOnBinding(bindingTarget: BindingTarget, value: any): void;
5353
logBindingUpdate(bindingTarget: BindingTarget, value: any): void;
54-
notifyOnAllChangesDone(): void;
54+
notifyAfterContentChecked(): void;
5555
}
5656

5757
export interface ChangeDetector {

modules/angular2/src/core/compiler/directive_lifecycle_reflector.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ bool hasLifecycleHook(LifecycleEvent e, type, DirectiveMetadata annotation) {
1313
final List interfaces = reflector.interfaces(type);
1414
var interface;
1515

16-
if (e == LifecycleEvent.onChange) {
17-
interface = OnChange;
18-
} else if (e == LifecycleEvent.onDestroy) {
16+
if (e == LifecycleEvent.OnChanges) {
17+
interface = OnChanges;
18+
} else if (e == LifecycleEvent.OnDestroy) {
1919
interface = OnDestroy;
20-
} else if (e == LifecycleEvent.onAllChangesDone) {
21-
interface = OnAllChangesDone;
22-
} else if (e == LifecycleEvent.onCheck) {
23-
interface = OnCheck;
24-
} else if (e == LifecycleEvent.onInit) {
20+
} else if (e == LifecycleEvent.AfterContentChecked) {
21+
interface = AfterContentChecked;
22+
} else if (e == LifecycleEvent.DoCheck) {
23+
interface = DoCheck;
24+
} else if (e == LifecycleEvent.OnInit) {
2525
interface = OnInit;
2626
}
2727

modules/angular2/src/core/compiler/directive_lifecycle_reflector.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ export function hasLifecycleHook(e: LifecycleEvent, type, annotation: DirectiveM
88
if (!(type instanceof Type)) return false;
99
var proto = (<any>type).prototype;
1010
switch (e) {
11-
case LifecycleEvent.onAllChangesDone:
12-
return !!proto.onAllChangesDone;
13-
case LifecycleEvent.onChange:
14-
return !!proto.onChange;
15-
case LifecycleEvent.onCheck:
16-
return !!proto.onCheck;
17-
case LifecycleEvent.onDestroy:
11+
case LifecycleEvent.AfterContentChecked:
12+
return !!proto.afterContentChecked;
13+
case LifecycleEvent.OnChanges:
14+
return !!proto.onChanges;
15+
case LifecycleEvent.DoCheck:
16+
return !!proto.doCheck;
17+
case LifecycleEvent.OnDestroy:
1818
return !!proto.onDestroy;
19-
case LifecycleEvent.onInit:
19+
case LifecycleEvent.OnInit:
2020
return !!proto.onInit;
2121
default:
2222
return false;

modules/angular2/src/core/compiler/element_injector.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ export class DirectiveBinding extends ResolvedBinding {
204204

205205
get callOnDestroy(): boolean { return this.metadata.callOnDestroy; }
206206

207-
get callOnChange(): boolean { return this.metadata.callOnChange; }
207+
get callOnChanges(): boolean { return this.metadata.callOnChanges; }
208208

209-
get callOnAllChangesDone(): boolean { return this.metadata.callOnAllChangesDone; }
209+
get callAfterContentChecked(): boolean { return this.metadata.callAfterContentChecked; }
210210

211211
get displayName(): string { return this.key.displayName; }
212212

@@ -238,11 +238,12 @@ export class DirectiveBinding extends ResolvedBinding {
238238
properties: ann.properties,
239239
readAttributes: DirectiveBinding._readAttributes(deps),
240240

241-
callOnDestroy: hasLifecycleHook(LifecycleEvent.onDestroy, rb.key.token, ann),
242-
callOnChange: hasLifecycleHook(LifecycleEvent.onChange, rb.key.token, ann),
243-
callOnCheck: hasLifecycleHook(LifecycleEvent.onCheck, rb.key.token, ann),
244-
callOnInit: hasLifecycleHook(LifecycleEvent.onInit, rb.key.token, ann),
245-
callOnAllChangesDone: hasLifecycleHook(LifecycleEvent.onAllChangesDone, rb.key.token, ann),
241+
callOnDestroy: hasLifecycleHook(LifecycleEvent.OnDestroy, rb.key.token, ann),
242+
callOnChanges: hasLifecycleHook(LifecycleEvent.OnChanges, rb.key.token, ann),
243+
callDoCheck: hasLifecycleHook(LifecycleEvent.DoCheck, rb.key.token, ann),
244+
callOnInit: hasLifecycleHook(LifecycleEvent.OnInit, rb.key.token, ann),
245+
callAfterContentChecked:
246+
hasLifecycleHook(LifecycleEvent.AfterContentChecked, rb.key.token, ann),
246247

247248
changeDetection: ann instanceof ComponentMetadata ? ann.changeDetection : null,
248249

@@ -431,7 +432,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
431432
this._strategy.dehydrate();
432433
}
433434

434-
onAllChangesDone(): void {
435+
afterContentChecked(): void {
435436
if (isPresent(this._query0) && this._query0.originator === this) {
436437
this._query0.list.fireCallbacks();
437438
}

0 commit comments

Comments
 (0)