refactor(ChangeDetector): rename WatchGroup into RecordRange
This commit is contained in:
@ -7,7 +7,7 @@ import {ClosureMap} from 'change_detection/parser/closure_map';
|
||||
import {Parser} from 'change_detection/parser/parser';
|
||||
import {Lexer} from 'change_detection/parser/lexer';
|
||||
import {ChangeDetector} from 'change_detection/change_detector';
|
||||
import {WatchGroup} from 'change_detection/watch_group';
|
||||
import {RecordRange} from 'change_detection/record_range';
|
||||
import {TemplateLoader} from './compiler/template_loader';
|
||||
import {Reflector} from './compiler/reflector';
|
||||
import {AnnotatedType} from './compiler/annotated_type';
|
||||
@ -56,7 +56,7 @@ export function documentDependentBindings(appComponentType) {
|
||||
});
|
||||
}, [Compiler, Injector, appElementToken, appComponentAnnotatedTypeToken]),
|
||||
|
||||
bind(appWatchGroupToken).toFactory((rootView) => rootView.watchGroup,
|
||||
bind(appWatchGroupToken).toFactory((rootView) => rootView.recordRange,
|
||||
[appViewToken]),
|
||||
bind(ChangeDetector).toFactory((appWatchGroup) =>
|
||||
new ChangeDetector(appWatchGroup), [appWatchGroupToken])
|
||||
|
@ -4,7 +4,7 @@ import {ListWrapper, List, MapWrapper, StringMapWrapper} from 'facade/collection
|
||||
|
||||
import {Parser} from 'change_detection/parser/parser';
|
||||
import {ClosureMap} from 'change_detection/parser/closure_map';
|
||||
import {ProtoWatchGroup} from 'change_detection/watch_group';
|
||||
import {ProtoRecordRange} from 'change_detection/record_range';
|
||||
|
||||
import {Directive} from '../../annotations/directive';
|
||||
import {Component} from '../../annotations/component';
|
||||
@ -20,7 +20,7 @@ import {CompileControl} from './compile_control';
|
||||
|
||||
/**
|
||||
* Creates the ElementBinders and adds watches to the
|
||||
* ProtoWatchGroup.
|
||||
* ProtoRecordRange.
|
||||
*
|
||||
* Fills:
|
||||
* - CompileElement#inheritedElementBinder
|
||||
|
@ -2,7 +2,7 @@ import {isPresent, BaseException} from 'facade/lang';
|
||||
import {ListWrapper, MapWrapper} from 'facade/collection';
|
||||
|
||||
import {ProtoView} from '../view';
|
||||
import {ProtoWatchGroup} from 'change_detection/watch_group';
|
||||
import {ProtoRecordRange} from 'change_detection/record_range';
|
||||
|
||||
import {CompileStep} from './compile_step';
|
||||
import {CompileElement} from './compile_element';
|
||||
@ -21,7 +21,7 @@ export class ProtoViewBuilder extends CompileStep {
|
||||
process(parent:CompileElement, current:CompileElement, control:CompileControl) {
|
||||
var inheritedProtoView = null;
|
||||
if (current.isViewRoot) {
|
||||
inheritedProtoView = new ProtoView(current.element, new ProtoWatchGroup());
|
||||
inheritedProtoView = new ProtoView(current.element, new ProtoRecordRange());
|
||||
if (isPresent(parent)) {
|
||||
if (isPresent(parent.inheritedElementBinder.nestedProtoView)) {
|
||||
throw new BaseException('Only one nested view per element is allowed');
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {DOM, Element, Node, Text, DocumentFragment, TemplateElement} from 'facade/dom';
|
||||
import {ListWrapper, MapWrapper} from 'facade/collection';
|
||||
import {ProtoWatchGroup, WatchGroup, WatchGroupDispatcher} from 'change_detection/watch_group';
|
||||
import {ProtoRecordRange, RecordRange, WatchGroupDispatcher} from 'change_detection/record_range';
|
||||
import {Record} from 'change_detection/record';
|
||||
import {AST} from 'change_detection/parser/ast';
|
||||
|
||||
@ -25,7 +25,7 @@ export class View {
|
||||
@FIELD('final elementInjectors:List<ElementInjector>')
|
||||
@FIELD('final bindElements:List<Element>')
|
||||
@FIELD('final textNodes:List<Text>')
|
||||
@FIELD('final watchGroup:WatchGroup')
|
||||
@FIELD('final recordRange:RecordRange')
|
||||
/// When the view is part of render tree, the DocumentFragment is empty, which is why we need
|
||||
/// to keep track of the nodes.
|
||||
@FIELD('final nodes:List<Node>')
|
||||
@ -33,15 +33,15 @@ export class View {
|
||||
@FIELD('childViews: List<View>')
|
||||
constructor(nodes:List<Node>, elementInjectors:List,
|
||||
rootElementInjectors:List, textNodes:List, bindElements:List,
|
||||
protoWatchGroup:ProtoWatchGroup, context) {
|
||||
protoRecordRange:ProtoRecordRange, context) {
|
||||
this.nodes = nodes;
|
||||
this.elementInjectors = elementInjectors;
|
||||
this.rootElementInjectors = rootElementInjectors;
|
||||
this.onChangeDispatcher = null;
|
||||
this.textNodes = textNodes;
|
||||
this.bindElements = bindElements;
|
||||
this.watchGroup = protoWatchGroup.instantiate(this, MapWrapper.create());
|
||||
this.watchGroup.setContext(context);
|
||||
this.recordRange = protoRecordRange.instantiate(this, MapWrapper.create());
|
||||
this.recordRange.setContext(context);
|
||||
// TODO(rado): Since this is only used in tests for now, investigate whether
|
||||
// we can remove it.
|
||||
this.childViews = [];
|
||||
@ -65,21 +65,21 @@ export class View {
|
||||
|
||||
addChild(childView: View) {
|
||||
ListWrapper.push(this.childViews, childView);
|
||||
this.watchGroup.addChild(childView.watchGroup);
|
||||
this.recordRange.addRange(childView.recordRange);
|
||||
}
|
||||
}
|
||||
|
||||
export class ProtoView {
|
||||
@FIELD('final element:Element')
|
||||
@FIELD('final elementBinders:List<ElementBinder>')
|
||||
@FIELD('final protoWatchGroup:ProtoWatchGroup')
|
||||
@FIELD('final protoRecordRange:ProtoRecordRange')
|
||||
constructor(
|
||||
template:Element,
|
||||
protoWatchGroup:ProtoWatchGroup) {
|
||||
protoRecordRange:ProtoRecordRange) {
|
||||
this.element = template;
|
||||
this.elementBinders = [];
|
||||
this.variableBindings = MapWrapper.create();
|
||||
this.protoWatchGroup = protoWatchGroup;
|
||||
this.protoRecordRange = protoRecordRange;
|
||||
this.textNodesWithBindingCount = 0;
|
||||
this.elementsWithBindingCount = 0;
|
||||
}
|
||||
@ -115,7 +115,7 @@ export class ProtoView {
|
||||
viewNodes = [clone];
|
||||
}
|
||||
var view = new View(viewNodes, elementInjectors, rootElementInjectors, textNodes,
|
||||
bindElements, this.protoWatchGroup, context);
|
||||
bindElements, this.protoRecordRange, context);
|
||||
|
||||
ProtoView._instantiateDirectives(
|
||||
view, elements, elementInjectors, lightDomAppInjector, shadowAppInjectors);
|
||||
@ -145,7 +145,7 @@ export class ProtoView {
|
||||
elBinder.textNodeIndices = ListWrapper.create();
|
||||
}
|
||||
ListWrapper.push(elBinder.textNodeIndices, indexInParent);
|
||||
this.protoWatchGroup.watch(expression, this.textNodesWithBindingCount++);
|
||||
this.protoRecordRange.addRecordsFromAST(expression, this.textNodesWithBindingCount++);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,7 +157,7 @@ export class ProtoView {
|
||||
elBinder.hasElementPropertyBindings = true;
|
||||
this.elementsWithBindingCount++;
|
||||
}
|
||||
this.protoWatchGroup.watch(expression,
|
||||
this.protoRecordRange.addRecordsFromAST(expression,
|
||||
new ElementPropertyMemento(
|
||||
this.elementsWithBindingCount-1,
|
||||
propertyName
|
||||
@ -184,7 +184,7 @@ export class ProtoView {
|
||||
expression:AST,
|
||||
setterName:string,
|
||||
setter:SetterFn) {
|
||||
this.protoWatchGroup.watch(
|
||||
this.protoRecordRange.addRecordsFromAST(
|
||||
expression,
|
||||
new DirectivePropertyMemento(
|
||||
this.elementBinders.length-1,
|
||||
@ -288,7 +288,7 @@ export class ProtoView {
|
||||
// Used for bootstrapping.
|
||||
static createRootProtoView(protoView: ProtoView,
|
||||
insertionElement, rootComponentAnnotatedType: AnnotatedType): ProtoView {
|
||||
var rootProtoView = new ProtoView(insertionElement, new ProtoWatchGroup());
|
||||
var rootProtoView = new ProtoView(insertionElement, new ProtoRecordRange());
|
||||
var binder = rootProtoView.bindElement(
|
||||
new ProtoElementInjector(null, 0, [rootComponentAnnotatedType.type], true));
|
||||
binder.componentDirective = rootComponentAnnotatedType;
|
||||
|
@ -9,7 +9,7 @@ export * from './annotations/template_config';
|
||||
export * from './application';
|
||||
|
||||
export * from 'change_detection/change_detector';
|
||||
export * from 'change_detection/watch_group';
|
||||
export * from 'change_detection/record_range';
|
||||
export * from 'change_detection/record';
|
||||
|
||||
export * from './compiler/compiler';
|
||||
|
Reference in New Issue
Block a user