refactor(ChandeDetection): Rename ChangeDetectorRef.markForCheck
BREAKING CHANGE Closes #3403 - ChangeDetectorRef.requestCheck() => ChangeDetectorRef.markForCheck()
This commit is contained in:
parent
b8be4bfaaf
commit
cebd670a8e
@ -220,11 +220,11 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
|
|||||||
this._createArrayToStoreObservables();
|
this._createArrayToStoreObservables();
|
||||||
if (isBlank(this.subscriptions[index])) {
|
if (isBlank(this.subscriptions[index])) {
|
||||||
this.streams[index] = value.changes;
|
this.streams[index] = value.changes;
|
||||||
this.subscriptions[index] = value.changes.listen((_) => this.ref.requestCheck());
|
this.subscriptions[index] = value.changes.listen((_) => this.ref.markForCheck());
|
||||||
} else if (this.streams[index] !== value.changes) {
|
} else if (this.streams[index] !== value.changes) {
|
||||||
this.subscriptions[index].cancel();
|
this.subscriptions[index].cancel();
|
||||||
this.streams[index] = value.changes;
|
this.streams[index] = value.changes;
|
||||||
this.subscriptions[index] = value.changes.listen((_) => this.ref.requestCheck());
|
this.subscriptions[index] = value.changes.listen((_) => this.ref.markForCheck());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
@ -236,7 +236,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
|
|||||||
this._createArrayToStoreObservables();
|
this._createArrayToStoreObservables();
|
||||||
var arrayIndex = this.numberOfPropertyProtoRecords + index + 2; // +1 is component
|
var arrayIndex = this.numberOfPropertyProtoRecords + index + 2; // +1 is component
|
||||||
this.streams[arrayIndex] = value.changes;
|
this.streams[arrayIndex] = value.changes;
|
||||||
this.subscriptions[arrayIndex] = value.changes.listen((_) => this.ref.requestCheck());
|
this.subscriptions[arrayIndex] = value.changes.listen((_) => this.ref.markForCheck());
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -247,7 +247,7 @@ export class AbstractChangeDetector<T> implements ChangeDetector {
|
|||||||
this._createArrayToStoreObservables();
|
this._createArrayToStoreObservables();
|
||||||
var index = this.numberOfPropertyProtoRecords + 1;
|
var index = this.numberOfPropertyProtoRecords + 1;
|
||||||
this.streams[index] = value.changes;
|
this.streams[index] = value.changes;
|
||||||
this.subscriptions[index] = value.changes.listen((_) => this.ref.requestCheck());
|
this.subscriptions[index] = value.changes.listen((_) => this.ref.markForCheck());
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ export class ChangeDetectorRef {
|
|||||||
/**
|
/**
|
||||||
* Request to check all OnPush ancestors.
|
* Request to check all OnPush ancestors.
|
||||||
*/
|
*/
|
||||||
requestCheck(): void { this._cd.markPathToRootAsCheckOnce(); }
|
markForCheck(): void { this._cd.markPathToRootAsCheckOnce(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detaches the change detector from the change detector tree.
|
* Detaches the change detector from the change detector tree.
|
||||||
@ -29,11 +29,10 @@ export class ChangeDetectorRef {
|
|||||||
* Reattach the change detector to the change detector tree.
|
* Reattach the change detector to the change detector tree.
|
||||||
*
|
*
|
||||||
* This also requests a check of this change detector. This reattached change detector will be
|
* This also requests a check of this change detector. This reattached change detector will be
|
||||||
*checked during the
|
* checked during the next change detection run.
|
||||||
* next change detection run.
|
|
||||||
*/
|
*/
|
||||||
reattach(): void {
|
reattach(): void {
|
||||||
this._cd.mode = ChangeDetectionStrategy.CheckAlways;
|
this._cd.mode = ChangeDetectionStrategy.CheckAlways;
|
||||||
this.requestCheck();
|
this.markForCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ class ObservableListDiff extends DefaultIterableDiffer {
|
|||||||
if (_subscription != null) _subscription.cancel();
|
if (_subscription != null) _subscription.cancel();
|
||||||
_subscription = collection.changes.listen((_) {
|
_subscription = collection.changes.listen((_) {
|
||||||
_updated = true;
|
_updated = true;
|
||||||
_ref.requestCheck();
|
_ref.markForCheck();
|
||||||
});
|
});
|
||||||
_updated = false;
|
_updated = false;
|
||||||
return super.diff(collection);
|
return super.diff(collection);
|
||||||
|
@ -124,7 +124,7 @@ export class AsyncPipe implements PipeTransform, PipeOnDestroy {
|
|||||||
_updateLatestValue(async: any, value: Object) {
|
_updateLatestValue(async: any, value: Object) {
|
||||||
if (async === this._obj) {
|
if (async === this._obj) {
|
||||||
this._latestValue = value;
|
this._latestValue = value;
|
||||||
this._ref.requestCheck();
|
this._ref.markForCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1685,7 +1685,7 @@ class PushCmpWithRef {
|
|||||||
return "fixed";
|
return "fixed";
|
||||||
}
|
}
|
||||||
|
|
||||||
propagate() { this.ref.requestCheck(); }
|
propagate() { this.ref.markForCheck(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({selector: 'push-cmp-with-async', changeDetection: ChangeDetectionStrategy.OnPush})
|
@Component({selector: 'push-cmp-with-async', changeDetection: ChangeDetectionStrategy.OnPush})
|
||||||
|
@ -73,7 +73,7 @@ main() {
|
|||||||
c.add(3);
|
c.add(3);
|
||||||
flushMicrotasks();
|
flushMicrotasks();
|
||||||
|
|
||||||
expect(changeDetectorRef.spy("requestCheck")).toHaveBeenCalledOnce();
|
expect(changeDetectorRef.spy("markForCheck")).toHaveBeenCalledOnce();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it("should return the wrapped value after changing a collection", () {
|
it("should return the wrapped value after changing a collection", () {
|
||||||
|
@ -91,7 +91,7 @@ export function main() {
|
|||||||
ObservableWrapper.callNext(emitter, message);
|
ObservableWrapper.callNext(emitter, message);
|
||||||
|
|
||||||
TimerWrapper.setTimeout(() => {
|
TimerWrapper.setTimeout(() => {
|
||||||
expect(ref.spy('requestCheck')).toHaveBeenCalled();
|
expect(ref.spy('markForCheck')).toHaveBeenCalled();
|
||||||
async.done();
|
async.done();
|
||||||
}, 0)
|
}, 0)
|
||||||
}));
|
}));
|
||||||
@ -178,7 +178,7 @@ export function main() {
|
|||||||
completer.resolve(message);
|
completer.resolve(message);
|
||||||
|
|
||||||
TimerWrapper.setTimeout(() => {
|
TimerWrapper.setTimeout(() => {
|
||||||
expect(ref.spy('requestCheck')).toHaveBeenCalled();
|
expect(ref.spy('markForCheck')).toHaveBeenCalled();
|
||||||
async.done();
|
async.done();
|
||||||
}, timer)
|
}, timer)
|
||||||
}));
|
}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user