feat(ChangeDetector): implement enabling/disabling watch group

This commit is contained in:
vsavkin
2014-11-18 17:26:38 -08:00
parent 41856ad3f0
commit 862c6412c4
5 changed files with 309 additions and 228 deletions

View File

@ -1,5 +1,5 @@
import {ProtoWatchGroup, WatchGroup} from './watch_group';
import {FIELD, isPresent, int, StringWrapper, FunctionWrapper, BaseException} from 'facade/lang';
import {FIELD, isPresent, isBlank, int, StringWrapper, FunctionWrapper, BaseException} from 'facade/lang';
import {ListWrapper, MapWrapper} from 'facade/collection';
import {ClosureMap} from 'change_detection/parser/closure_map';
@ -105,6 +105,11 @@ export class Record {
this.funcOrValue = null;
this.args = null;
if (isBlank(protoRecord)) {
this.mode = MODE_STATE_MARKER;
return;
}
var type = protoRecord.recordType;
if (type === PROTO_RECORD_CONST) {
this.mode = MODE_STATE_CONST;
@ -135,6 +140,12 @@ export class Record {
}
}
static createMarker(wg:WatchGroup) {
var r = new Record(wg, null, null);
r.disabled = true;
return r;
}
check():boolean {
this.previousValue = this.currentValue;
this.currentValue = this._calculateNewValue();
@ -200,7 +211,13 @@ export class Record {
updateContext(value) {
this.context = value;
this.watchGroup.enableRecord(this);
if (! this.isMarkerRecord) {
this.watchGroup.enableRecord(this);
}
}
get isMarkerRecord() {
return isBlank(this.protoRecord);
}
}