Skip to content

Commit 9c7c7e8

Browse files
committed
design: simplified view interfaces
1 parent 39c03e6 commit 9c7c7e8

16 files changed

Lines changed: 149 additions & 104 deletions

modules/change_detection/src/change_detection.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ export class ChangeDetection {
1111
detectChanges():int {
1212
var current:Record = _rootWatchGroup._headRecord;
1313
var count:number = 0;
14-
while(current != null) {
15-
if(current.check()) {
14+
while (current != null) {
15+
if (current.check()) {
1616
count++;
1717
}
1818
}
1919
return count;
2020
}
21-
2221
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
library change_detection.facade;
2+
3+
typedef SetterFn(Object obj, value);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export var SetterFn = Function;

modules/change_detection/src/record.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export class ProtoRecord {
2323
constructor(watchGroup:ProtoWatchGroup, fieldName:String) {
2424
this.watchGroup = watchGroup;
2525
this.fieldName = fieldName;
26-
this._next = null;
27-
this._prev = null;
26+
this.next = null;
27+
this.prev = null;
2828
this._checkNext = null;
2929
this._checkPrev = null;
3030
this._notifierNext = null;
@@ -36,17 +36,17 @@ export class ProtoRecord {
3636

3737
instantiate(watchGroup:WatchGroup):Record {
3838
var record = this._clone = new Record(watchGroup, this);
39-
record._prev = this._prev._clone;
39+
record.prev = this.prev._clone;
4040
record._checkPrev = this._checkPrev._clone;
4141
return _clone;
4242
}
4343

4444
instantiateComplete():Record {
4545
var record = this._clone;
46-
record._next = this._next._clone;
46+
record.next = this.next._clone;
4747
record._checkNext = this._checkNext._clone;
4848
this._clone = null;
49-
return this._next;
49+
return this.next;
5050
}
5151
}
5252

@@ -97,8 +97,8 @@ export class Record {
9797
constructor(watchGroup:WatchGroup, protoRecord:ProtoRecord) {
9898
this.protoRecord = protoRecord;
9999
this.watchGroup = watchGroup;
100-
this._next = null;
101-
this._prev = null;
100+
this.next = null;
101+
this.prev = null;
102102
this._checkNext = null;
103103
this._checkPrev = null;
104104
this._notifierNext = null;

modules/change_detection/src/watch_group.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {ProtoRecord, Record} from './record';
2-
import {WatchGroupDispatcher} from './watch_group_dispatcher';
32

43
export class ProtoWatchGroup {
54
@FIELD('final _headRecord:ProtoRecord')
@@ -31,7 +30,8 @@ export class ProtoWatchGroup {
3130

3231
proto = this._headRecord;
3332
while(proto != null) {
34-
proto = proto.instantiateComplete();
33+
proto.instantiateComplete();
34+
proto = proto.next;
3535
}
3636

3737
watchGroup._headRecord = head;
@@ -61,3 +61,7 @@ export class WatchGroup {
6161
}
6262

6363
}
64+
65+
export class WatchGroupDispatcher {
66+
onRecordChange(record:Record, context) {}
67+
}

modules/change_detection/src/watch_group_dispatcher.js

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:di/di.dart' show Module;
2-
import '../view/element_module.dart' show ElementModule;
2+
import '../compiler/element_module.dart' show ElementModule;
33

44
typedef DomServicesFunction(ElementModule m);
5-
typedef ComponentServicesFunction(Module m);
5+
typedef ComponentServicesFunction(Module m);

modules/core/src/compiler/compiler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Future, Type} from 'facade/lang';
22
import {Element} from 'facade/dom';
3-
import {ProtoView} from '../view/proto_view';
3+
import {ProtoView} from './view';
44
import {TemplateLoader} from './template_loader';
55

66
export class Compiler {
@@ -23,4 +23,4 @@ export class Compiler {
2323
}
2424

2525

26-
}
26+
}

modules/core/src/view/proto_element_injector.js renamed to modules/core/src/compiler/element_injector.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,25 @@ ElementInjector (ElementModule):
1717
- Query mechanism for children
1818
- 1:1 to DOM structure.
1919
*/
20-
20+
2121
export class ProtoElementInjector {
2222
@FIELD('final _parent:ProtoElementInjector')
2323
/// Temporory instance while instantiating
24-
@FIELD('_instance:ElementInjector')
25-
constructor() {}
24+
@FIELD('_clone:ElementInjector')
25+
constructor(parent:ProtoElementInjector) {
26+
this._parent = parent;
27+
}
28+
29+
instantiate():ElementInjector {
30+
return new ElementInjector(this);
31+
}
32+
}
33+
34+
export class ElementInjector {
35+
@FIELD('final protoInjector:ProtoElementInjector')
36+
constructor(protoInjector:ProtoElementInjector) {
37+
this.protoInjector = protoInjector;
38+
}
39+
2640
}
27-
41+
File renamed without changes.

0 commit comments

Comments
 (0)