Skip to content

Commit cebd670

Browse files
committed
refactor(ChandeDetection): Rename ChangeDetectorRef.markForCheck
BREAKING CHANGE Closes angular#3403 - ChangeDetectorRef.requestCheck() => ChangeDetectorRef.markForCheck()
1 parent b8be4bf commit cebd670

File tree

7 files changed

+13
-14
lines changed

7 files changed

+13
-14
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
220220
this._createArrayToStoreObservables();
221221
if (isBlank(this.subscriptions[index])) {
222222
this.streams[index] = value.changes;
223-
this.subscriptions[index] = value.changes.listen((_) => this.ref.requestCheck());
223+
this.subscriptions[index] = value.changes.listen((_) => this.ref.markForCheck());
224224
} else if (this.streams[index] !== value.changes) {
225225
this.subscriptions[index].cancel();
226226
this.streams[index] = value.changes;
227-
this.subscriptions[index] = value.changes.listen((_) => this.ref.requestCheck());
227+
this.subscriptions[index] = value.changes.listen((_) => this.ref.markForCheck());
228228
}
229229
}
230230
return value;
@@ -236,7 +236,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
236236
this._createArrayToStoreObservables();
237237
var arrayIndex = this.numberOfPropertyProtoRecords + index + 2; // +1 is component
238238
this.streams[arrayIndex] = value.changes;
239-
this.subscriptions[arrayIndex] = value.changes.listen((_) => this.ref.requestCheck());
239+
this.subscriptions[arrayIndex] = value.changes.listen((_) => this.ref.markForCheck());
240240
}
241241
return value;
242242
}
@@ -247,7 +247,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
247247
this._createArrayToStoreObservables();
248248
var index = this.numberOfPropertyProtoRecords + 1;
249249
this.streams[index] = value.changes;
250-
this.subscriptions[index] = value.changes.listen((_) => this.ref.requestCheck());
250+
this.subscriptions[index] = value.changes.listen((_) => this.ref.markForCheck());
251251
}
252252
return value;
253253
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class ChangeDetectorRef {
1616
/**
1717
* Request to check all OnPush ancestors.
1818
*/
19-
requestCheck(): void { this._cd.markPathToRootAsCheckOnce(); }
19+
markForCheck(): void { this._cd.markPathToRootAsCheckOnce(); }
2020

2121
/**
2222
* Detaches the change detector from the change detector tree.
@@ -29,11 +29,10 @@ export class ChangeDetectorRef {
2929
* Reattach the change detector to the change detector tree.
3030
*
3131
* This also requests a check of this change detector. This reattached change detector will be
32-
*checked during the
33-
* next change detection run.
32+
* checked during the next change detection run.
3433
*/
3534
reattach(): void {
3635
this._cd.mode = ChangeDetectionStrategy.CheckAlways;
37-
this.requestCheck();
36+
this.markForCheck();
3837
}
3938
}

modules/angular2/src/core/directives/observable_list_diff.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ObservableListDiff extends DefaultIterableDiffer {
3535
if (_subscription != null) _subscription.cancel();
3636
_subscription = collection.changes.listen((_) {
3737
_updated = true;
38-
_ref.requestCheck();
38+
_ref.markForCheck();
3939
});
4040
_updated = false;
4141
return super.diff(collection);

modules/angular2/src/core/pipes/async_pipe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class AsyncPipe implements PipeTransform, PipeOnDestroy {
124124
_updateLatestValue(async: any, value: Object) {
125125
if (async === this._obj) {
126126
this._latestValue = value;
127-
this._ref.requestCheck();
127+
this._ref.markForCheck();
128128
}
129129
}
130130
}

modules/angular2/test/core/compiler/integration_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,7 @@ class PushCmpWithRef {
16851685
return "fixed";
16861686
}
16871687

1688-
propagate() { this.ref.requestCheck(); }
1688+
propagate() { this.ref.markForCheck(); }
16891689
}
16901690

16911691
@Component({selector: 'push-cmp-with-async', changeDetection: ChangeDetectionStrategy.OnPush})

modules/angular2/test/core/directives/observable_list_diff_spec.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ main() {
7373
c.add(3);
7474
flushMicrotasks();
7575

76-
expect(changeDetectorRef.spy("requestCheck")).toHaveBeenCalledOnce();
76+
expect(changeDetectorRef.spy("markForCheck")).toHaveBeenCalledOnce();
7777
}));
7878

7979
it("should return the wrapped value after changing a collection", () {

modules/angular2/test/pipes/async_pipe_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function main() {
9191
ObservableWrapper.callNext(emitter, message);
9292

9393
TimerWrapper.setTimeout(() => {
94-
expect(ref.spy('requestCheck')).toHaveBeenCalled();
94+
expect(ref.spy('markForCheck')).toHaveBeenCalled();
9595
async.done();
9696
}, 0)
9797
}));
@@ -178,7 +178,7 @@ export function main() {
178178
completer.resolve(message);
179179

180180
TimerWrapper.setTimeout(() => {
181-
expect(ref.spy('requestCheck')).toHaveBeenCalled();
181+
expect(ref.spy('markForCheck')).toHaveBeenCalled();
182182
async.done();
183183
}, timer)
184184
}));

0 commit comments

Comments
 (0)