Skip to content

Commit 2980eb5

Browse files
committed
refactor(ChangeDetector): rename WatchGroup into RecordRange
1 parent 862c641 commit 2980eb5

File tree

14 files changed

+411
-384
lines changed

14 files changed

+411
-384
lines changed

modules/change_detection/src/change_detector.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
import {ProtoWatchGroup, WatchGroup} from './watch_group';
1+
import {ProtoRecordRange, RecordRange} from './record_range';
22
import {ProtoRecord, Record} from './record';
33
import {FIELD, int, isPresent} from 'facade/lang';
4+
45
export * from './record';
5-
export * from './watch_group'
6+
export * from './record_range'
67

78
export class ChangeDetector {
89

9-
@FIELD('final _rootWatchGroup:WatchGroup')
10-
constructor(watchGroup:WatchGroup) {
11-
this._rootWatchGroup = watchGroup;
10+
@FIELD('final _rootRecordRange:RecordRange')
11+
constructor(recordRange:RecordRange) {
12+
this._rootRecordRange = recordRange;
1213
}
1314

1415
detectChanges():int {
1516
var count:int = 0;
16-
for (var record = this._rootWatchGroup.findFirstEnabledRecord();
17+
for (var record = this._rootRecordRange.findFirstEnabledRecord();
1718
isPresent(record);
1819
record = record.nextEnabled) {
1920
if (record.check()) {

modules/change_detection/src/record.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ProtoWatchGroup, WatchGroup} from './watch_group';
1+
import {ProtoRecordRange, RecordRange} from './record_range';
22
import {FIELD, isPresent, isBlank, int, StringWrapper, FunctionWrapper, BaseException} from 'facade/lang';
33
import {ListWrapper, MapWrapper} from 'facade/collection';
44
import {ClosureMap} from 'change_detection/parser/closure_map';
@@ -17,7 +17,7 @@ export const PROTO_RECORD_PROPERTY = 'property';
1717
* real world numbers show that it does not provide significant benefits.
1818
*/
1919
export class ProtoRecord {
20-
@FIELD('final watchGroup:wg.ProtoWatchGroup')
20+
@FIELD('final recordRange:ProtoRecordRange')
2121
@FIELD('final context:Object')
2222
@FIELD('final funcOrValue:Object')
2323
@FIELD('final arity:int')
@@ -26,13 +26,13 @@ export class ProtoRecord {
2626
@FIELD('next:ProtoRecord')
2727
@FIELD('prev:ProtoRecord')
2828
@FIELD('recordInConstruction:Record')
29-
constructor(watchGroup:ProtoWatchGroup,
29+
constructor(recordRange:ProtoRecordRange,
3030
recordType:string,
3131
funcOrValue,
3232
arity:int,
3333
dest) {
3434

35-
this.watchGroup = watchGroup;
35+
this.recordRange = recordRange;
3636
this.recordType = recordType;
3737
this.funcOrValue = funcOrValue;
3838
this.arity = arity;
@@ -61,7 +61,7 @@ export class ProtoRecord {
6161
* - Keep this object as lean as possible. (Lean in number of fields)
6262
*/
6363
export class Record {
64-
@FIELD('final watchGroup:WatchGroup')
64+
@FIELD('final recordRange:RecordRange')
6565
@FIELD('final protoRecord:ProtoRecord')
6666
@FIELD('next:Record')
6767
@FIELD('prev:Record')
@@ -86,8 +86,8 @@ export class Record {
8686
// Otherwise it is the context used by WatchGroupDispatcher.
8787
@FIELD('dest')
8888

89-
constructor(watchGroup:WatchGroup, protoRecord:ProtoRecord, formatters:Map) {
90-
this.watchGroup = watchGroup;
89+
constructor(recordRange:RecordRange, protoRecord:ProtoRecord, formatters:Map) {
90+
this.recordRange = recordRange;
9191
this.protoRecord = protoRecord;
9292

9393
this.next = null;
@@ -140,8 +140,8 @@ export class Record {
140140
}
141141
}
142142

143-
static createMarker(wg:WatchGroup) {
144-
var r = new Record(wg, null, null);
143+
static createMarker(rr:RecordRange) {
144+
var r = new Record(rr, null, null);
145145
r.disabled = true;
146146
return r;
147147
}
@@ -166,7 +166,7 @@ export class Record {
166166
this.dest.updateContext(this.currentValue);
167167
}
168168
} else {
169-
this.watchGroup.dispatcher.onRecordChange(this, this.protoRecord.dest);
169+
this.recordRange.dispatcher.onRecordChange(this, this.protoRecord.dest);
170170
}
171171
}
172172

@@ -183,11 +183,11 @@ export class Record {
183183
return FunctionWrapper.apply(this.context, this.args);
184184

185185
case MODE_STATE_INVOKE_PURE_FUNCTION:
186-
this.watchGroup.disableRecord(this);
186+
this.recordRange.disableRecord(this);
187187
return FunctionWrapper.apply(this.funcOrValue, this.args);
188188

189189
case MODE_STATE_CONST:
190-
this.watchGroup.disableRecord(this);
190+
this.recordRange.disableRecord(this);
191191
return this.funcOrValue;
192192

193193
case MODE_STATE_MARKER:
@@ -206,18 +206,18 @@ export class Record {
206206

207207
updateArg(value, position:int) {
208208
this.args[position] = value;
209-
this.watchGroup.enableRecord(this);
209+
this.recordRange.enableRecord(this);
210210
}
211211

212212
updateContext(value) {
213213
this.context = value;
214-
if (! this.isMarkerRecord) {
215-
this.watchGroup.enableRecord(this);
214+
if (!this.isMarkerRecord) {
215+
this.recordRange.enableRecord(this);
216216
}
217217
}
218218

219219
get isMarkerRecord() {
220-
return isBlank(this.protoRecord);
220+
return this.mode == MODE_STATE_MARKER;
221221
}
222222
}
223223

0 commit comments

Comments
 (0)