-
Notifications
You must be signed in to change notification settings - Fork 248
[WIP] feat(ChangeDetector): unified architecture #1348
Conversation
Notes There is a breaking change in this PR. When a This makes the implementation more efficient has we don't have to possibly In the process the behavior seems better now (see the last assert): it('should support switching refs - gh 1158', async(() {
var list = [0];
var record = detector.watch(list, null, null);
if (detector.collectChanges().moveNext()) {
detector.collectChanges();
}
record.object = [1, 0];
var iterator = detector.collectChanges()..moveNext();
expect(...);
record.object = [2, 1, 0];
iterator = detector.collectChanges()..moveNext();
expect(iterator.current.currentValue, toEqualCollectionRecord(
collection: ['2[null -> 0]', '1[null -> 1]', '0[0 -> 2]'],
previous: ['0[0 -> 2]'],
additions: ['2[null -> 0]', '1[null -> 1]'],
moves: ['0[0 -> 2]'],
removals: []));
})); New behavior: it('should support switching refs - gh 1158', async(() {
var value;
context['list'] = [0];
var group = detector.createWatchGroup(context);
group.watch(parse('list', collection: true), (v, _) => value = v);
group.processChanges();
context['list'] = [1, 0];
group.processChanges();
expect(...);
context['list'] = [2, 1, 0];
group.processChanges();
expect(value, toEqualCollectionRecord(
collection: ['2[null -> 0]', '1[0 -> 1]', '0[1 -> 2]'],
previous: ['1[0 -> 1]', '0[1 -> 2]'],
additions: ['2[null -> 0]'],
moves: ['1[0 -> 1]', '0[1 -> 2]']));
})); |
ChangeDetector(this._fieldGetterFactory); | ||
|
||
/// Creates a root watch group | ||
WatchGroup createWatchGroup(Object context) => new WatchGroup(null, context, _fieldGetterFactory); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to talk about this more in depth. But my latest thinking is that we can not create WatchGroup with context. The context needs to be something which we can assign later. The reason for this is that we want to be able to reset the context at runtime. The benefit would be to be able to reuse an instance of WatchGroup for performance reasons. Let's discus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting the context later should be implemented with the ProtoWatchGroup / ProtoRecord
8fd235c
to
50e2645
Compare
@mhevery Could you please check the latest commit ("fixup: do not detach if not attached"). It is here to fix an issue with this test where the ng-if contains a content directive. The directive is both All tests now pass with the new architecture, it would be great to test g3 code with this to see if everything works as expected. |
Closing In favor for v2 |
This PR is a WIP and will be subject to changes
Status:
The PR should be closed to feature parity with the former implementation.
What I'll do next is to:
To do:
To discuss: