2015-02-02 16:25:34 -08:00
|
|
|
import {List, ListWrapper} from 'facade/src/collection';
|
2015-01-21 12:05:52 -08:00
|
|
|
import {ChangeDetector} from './interfaces';
|
|
|
|
|
|
|
|
export class AbstractChangeDetector extends ChangeDetector {
|
|
|
|
children:List;
|
|
|
|
parent:ChangeDetector;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
this.children = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
addChild(cd:ChangeDetector) {
|
|
|
|
ListWrapper.push(this.children, cd);
|
|
|
|
cd.parent = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
removeChild(cd:ChangeDetector) {
|
|
|
|
ListWrapper.remove(this.children, cd);
|
|
|
|
}
|
|
|
|
|
|
|
|
remove() {
|
|
|
|
this.parent.removeChild(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
detectChanges() {
|
|
|
|
this._detectChanges(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
checkNoChanges() {
|
|
|
|
this._detectChanges(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
_detectChanges(throwOnChange:boolean) {
|
|
|
|
this.detectChangesInRecords(throwOnChange);
|
|
|
|
this._detectChangesInChildren(throwOnChange);
|
|
|
|
}
|
|
|
|
|
|
|
|
detectChangesInRecords(throwOnChange:boolean){}
|
|
|
|
|
|
|
|
_detectChangesInChildren(throwOnChange:boolean) {
|
|
|
|
var children = this.children;
|
|
|
|
for(var i = 0; i < children.length; ++i) {
|
|
|
|
children[i]._detectChanges(throwOnChange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|