refactor(change_detection): removed global change detection objects so it is possible to override pipe registry
This commit is contained in:
parent
233cb0f96a
commit
5408abca68
|
@ -25,5 +25,5 @@ export {PipeRegistry} from './src/change_detection/pipes/pipe_registry';
|
||||||
export {uninitialized} from './src/change_detection/change_detection_util';
|
export {uninitialized} from './src/change_detection/change_detection_util';
|
||||||
export {NO_CHANGE, Pipe} from './src/change_detection/pipes/pipe';
|
export {NO_CHANGE, Pipe} from './src/change_detection/pipes/pipe';
|
||||||
export {
|
export {
|
||||||
defaultPipes, DynamicChangeDetection, JitChangeDetection, dynamicChangeDetection, jitChangeDetection
|
defaultPipes, DynamicChangeDetection, JitChangeDetection, defaultPipeRegistry
|
||||||
} from './src/change_detection/change_detection';
|
} from './src/change_detection/change_detection';
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {KeyValueChangesFactory} from './pipes/keyvalue_changes';
|
||||||
import {NullPipeFactory} from './pipes/null_pipe';
|
import {NullPipeFactory} from './pipes/null_pipe';
|
||||||
import {DEFAULT} from './constants';
|
import {DEFAULT} from './constants';
|
||||||
import {ChangeDetection, ProtoChangeDetector} from './interfaces';
|
import {ChangeDetection, ProtoChangeDetector} from './interfaces';
|
||||||
|
import {Injectable} from 'angular2/di';
|
||||||
|
|
||||||
export var defaultPipes = {
|
export var defaultPipes = {
|
||||||
"iterableDiff" : [
|
"iterableDiff" : [
|
||||||
|
@ -17,6 +18,10 @@ export var defaultPipes = {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exportedAs angular2/change_detection
|
||||||
|
*/
|
||||||
|
@Injectable()
|
||||||
export class DynamicChangeDetection extends ChangeDetection {
|
export class DynamicChangeDetection extends ChangeDetection {
|
||||||
registry:PipeRegistry;
|
registry:PipeRegistry;
|
||||||
|
|
||||||
|
@ -30,6 +35,10 @@ export class DynamicChangeDetection extends ChangeDetection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @exportedAs angular2/change_detection
|
||||||
|
*/
|
||||||
|
@Injectable()
|
||||||
export class JitChangeDetection extends ChangeDetection {
|
export class JitChangeDetection extends ChangeDetection {
|
||||||
registry:PipeRegistry;
|
registry:PipeRegistry;
|
||||||
|
|
||||||
|
@ -43,18 +52,4 @@ export class JitChangeDetection extends ChangeDetection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _registry = new PipeRegistry(defaultPipes);
|
export var defaultPipeRegistry = new PipeRegistry(defaultPipes);
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements dynamic change detection. See: [ChangeDetection] for more details.
|
|
||||||
*
|
|
||||||
* @exportedAs angular2/change_detection
|
|
||||||
*/
|
|
||||||
export var dynamicChangeDetection = new DynamicChangeDetection(_registry);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements just-in-time change detection. See: [ChangeDetection] for more details.
|
|
||||||
*
|
|
||||||
* @exportedAs angular2/change_detection
|
|
||||||
*/
|
|
||||||
export var jitChangeDetection = new JitChangeDetection(_registry);
|
|
|
@ -1,8 +1,10 @@
|
||||||
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
import {List, ListWrapper} from 'angular2/src/facade/collection';
|
||||||
import {isBlank, isPresent, BaseException, CONST} from 'angular2/src/facade/lang';
|
import {isBlank, isPresent, BaseException, CONST} from 'angular2/src/facade/lang';
|
||||||
import {Pipe} from './pipe';
|
import {Pipe} from './pipe';
|
||||||
|
import {Injectable} from 'angular2/di';
|
||||||
import {ChangeDetectorRef} from '../change_detector_ref';
|
import {ChangeDetectorRef} from '../change_detector_ref';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
export class PipeRegistry {
|
export class PipeRegistry {
|
||||||
config;
|
config;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
|
||||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||||
import {Compiler, CompilerCache} from './compiler/compiler';
|
import {Compiler, CompilerCache} from './compiler/compiler';
|
||||||
import {Reflector, reflector} from 'angular2/src/reflection/reflection';
|
import {Reflector, reflector} from 'angular2/src/reflection/reflection';
|
||||||
import {Parser, Lexer, ChangeDetection, dynamicChangeDetection, jitChangeDetection} from 'angular2/change_detection';
|
import {Parser, Lexer, ChangeDetection, DynamicChangeDetection, PipeRegistry, defaultPipeRegistry} from 'angular2/change_detection';
|
||||||
import {ExceptionHandler} from './exception_handler';
|
import {ExceptionHandler} from './exception_handler';
|
||||||
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
||||||
import {TemplateResolver} from './compiler/template_resolver';
|
import {TemplateResolver} from './compiler/template_resolver';
|
||||||
|
@ -113,7 +113,8 @@ function _injectorBindings(appComponentType): List<Binding> {
|
||||||
Compiler,
|
Compiler,
|
||||||
CompilerCache,
|
CompilerCache,
|
||||||
TemplateResolver,
|
TemplateResolver,
|
||||||
bind(ChangeDetection).toValue(dynamicChangeDetection),
|
bind(PipeRegistry).toValue(defaultPipeRegistry),
|
||||||
|
bind(ChangeDetection).toClass(DynamicChangeDetection),
|
||||||
TemplateLoader,
|
TemplateLoader,
|
||||||
DirectiveMetadataReader,
|
DirectiveMetadataReader,
|
||||||
Parser,
|
Parser,
|
||||||
|
|
|
@ -2,7 +2,8 @@ import {bind} from 'angular2/di';
|
||||||
|
|
||||||
import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
|
import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
|
||||||
import {Reflector, reflector} from 'angular2/src/reflection/reflection';
|
import {Reflector, reflector} from 'angular2/src/reflection/reflection';
|
||||||
import {Parser, Lexer, ChangeDetection, dynamicChangeDetection} from 'angular2/change_detection';
|
import {Parser, Lexer, ChangeDetection, DynamicChangeDetection,
|
||||||
|
PipeRegistry, defaultPipeRegistry} from 'angular2/change_detection';
|
||||||
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
|
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
|
||||||
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
import {TemplateLoader} from 'angular2/src/render/dom/compiler/template_loader';
|
||||||
import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver';
|
import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver';
|
||||||
|
@ -90,7 +91,8 @@ function _getAppBindings() {
|
||||||
Compiler,
|
Compiler,
|
||||||
CompilerCache,
|
CompilerCache,
|
||||||
bind(TemplateResolver).toClass(MockTemplateResolver),
|
bind(TemplateResolver).toClass(MockTemplateResolver),
|
||||||
bind(ChangeDetection).toValue(dynamicChangeDetection),
|
bind(PipeRegistry).toValue(defaultPipeRegistry),
|
||||||
|
bind(ChangeDetection).toClass(DynamicChangeDetection),
|
||||||
TemplateLoader,
|
TemplateLoader,
|
||||||
DynamicComponentLoader,
|
DynamicComponentLoader,
|
||||||
DirectiveMetadataReader,
|
DirectiveMetadataReader,
|
||||||
|
|
|
@ -21,8 +21,8 @@ import {Type, isPresent, BaseException, assertionsEnabled, isJsObject, global} f
|
||||||
import {PromiseWrapper, EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
import {PromiseWrapper, EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
|
||||||
|
|
||||||
import {Injector, bind} from 'angular2/di';
|
import {Injector, bind} from 'angular2/di';
|
||||||
import {dynamicChangeDetection,
|
import {PipeRegistry, defaultPipeRegistry,
|
||||||
ChangeDetection, DynamicChangeDetection, Pipe, PipeRegistry, ChangeDetectorRef, ON_PUSH} from 'angular2/change_detection';
|
ChangeDetection, DynamicChangeDetection, Pipe, ChangeDetectorRef, ON_PUSH} from 'angular2/change_detection';
|
||||||
|
|
||||||
import {Decorator, Component, Viewport, DynamicComponent} from 'angular2/src/core/annotations/annotations';
|
import {Decorator, Component, Viewport, DynamicComponent} from 'angular2/src/core/annotations/annotations';
|
||||||
import {View} from 'angular2/src/core/annotations/view';
|
import {View} from 'angular2/src/core/annotations/view';
|
||||||
|
|
|
@ -9,8 +9,8 @@ import {
|
||||||
Parser,
|
Parser,
|
||||||
ChangeDispatcher,
|
ChangeDispatcher,
|
||||||
ChangeDetection,
|
ChangeDetection,
|
||||||
dynamicChangeDetection,
|
DynamicChangeDetection,
|
||||||
jitChangeDetection,
|
JitChangeDetection,
|
||||||
BindingRecord,
|
BindingRecord,
|
||||||
DirectiveRecord,
|
DirectiveRecord,
|
||||||
DEFAULT
|
DEFAULT
|
||||||
|
@ -261,7 +261,7 @@ export function main () {
|
||||||
|
|
||||||
|
|
||||||
// -- DYNAMIC
|
// -- DYNAMIC
|
||||||
var ng2DynamicChangeDetector = setUpChangeDetection(dynamicChangeDetection, numberOfDetectors, object);
|
var ng2DynamicChangeDetector = setUpChangeDetection(new DynamicChangeDetection(null), numberOfDetectors, object);
|
||||||
|
|
||||||
runChangeDetectionReads(ng2DynamicChangeDetector, 1); //warmup
|
runChangeDetectionReads(ng2DynamicChangeDetector, 1); //warmup
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ export function main () {
|
||||||
// -- JIT
|
// -- JIT
|
||||||
// Reenable when we have transformers for Dart
|
// Reenable when we have transformers for Dart
|
||||||
if (isJsObject({})) {
|
if (isJsObject({})) {
|
||||||
var ng2JitChangeDetector = setUpChangeDetection(jitChangeDetection, numberOfDetectors, object);
|
var ng2JitChangeDetector = setUpChangeDetection(new JitChangeDetection(null), numberOfDetectors, object);
|
||||||
|
|
||||||
runChangeDetectionReads(ng2JitChangeDetector, 1); //warmup
|
runChangeDetectionReads(ng2JitChangeDetector, 1); //warmup
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {MapWrapper} from 'angular2/src/facade/collection';
|
||||||
import {DirectiveMetadata} from 'angular2/src/core/compiler/directive_metadata';
|
import {DirectiveMetadata} from 'angular2/src/core/compiler/directive_metadata';
|
||||||
import {NativeShadowDomStrategy} from 'angular2/src/render/dom/shadow_dom/native_shadow_dom_strategy';
|
import {NativeShadowDomStrategy} from 'angular2/src/render/dom/shadow_dom/native_shadow_dom_strategy';
|
||||||
|
|
||||||
import {Parser, Lexer, ProtoRecordRange, dynamicChangeDetection} from 'angular2/change_detection';
|
import {Parser, Lexer, ProtoRecordRange, DynamicChangeDetection} from 'angular2/change_detection';
|
||||||
|
|
||||||
import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
|
import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
|
||||||
import {DirectiveMetadataReader} from 'angular2/src/core/compiler/directive_metadata_reader';
|
import {DirectiveMetadataReader} from 'angular2/src/core/compiler/directive_metadata_reader';
|
||||||
|
@ -82,7 +82,7 @@ export function main() {
|
||||||
new ComponentUrlMapper(),
|
new ComponentUrlMapper(),
|
||||||
urlResolver,
|
urlResolver,
|
||||||
renderer,
|
renderer,
|
||||||
new ProtoViewFactory(dynamicChangeDetection)
|
new ProtoViewFactory(new DynamicChangeDetection(null))
|
||||||
);
|
);
|
||||||
var templateNoBindings = createTemplateHtml('templateNoBindings', count);
|
var templateNoBindings = createTemplateHtml('templateNoBindings', count);
|
||||||
var templateWithBindings = createTemplateHtml('templateWithBindings', count);
|
var templateWithBindings = createTemplateHtml('templateWithBindings', count);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as app from './index_common';
|
import * as app from './index_common';
|
||||||
|
|
||||||
import {Component, Decorator, View, NgElement} from 'angular2/angular2';
|
import {Component, Decorator, View, NgElement} from 'angular2/angular2';
|
||||||
import {Lexer, Parser, ChangeDetection, ChangeDetector} from 'angular2/change_detection';
|
import {Lexer, Parser, ChangeDetection, ChangeDetector, PipeRegistry, DynamicChangeDetection} from 'angular2/change_detection';
|
||||||
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
|
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
|
||||||
import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
|
import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
|
||||||
|
|
||||||
|
@ -248,6 +248,12 @@ function setup() {
|
||||||
"annotations": []
|
"annotations": []
|
||||||
});
|
});
|
||||||
|
|
||||||
|
reflector.registerType(DynamicChangeDetection, {
|
||||||
|
"factory": (registry) => new DynamicChangeDetection(registry),
|
||||||
|
"parameters": [[PipeRegistry]],
|
||||||
|
"annotations": []
|
||||||
|
});
|
||||||
|
|
||||||
reflector.registerType(DirectDomRenderer, {
|
reflector.registerType(DirectDomRenderer, {
|
||||||
"factory": (renderCompiler, renderViewFactory, renderViewHydrator, shadowDomStrategy) =>
|
"factory": (renderCompiler, renderViewFactory, renderViewHydrator, shadowDomStrategy) =>
|
||||||
new DirectDomRenderer(renderCompiler, renderViewFactory, renderViewHydrator, shadowDomStrategy),
|
new DirectDomRenderer(renderCompiler, renderViewFactory, renderViewHydrator, shadowDomStrategy),
|
||||||
|
|
Loading…
Reference in New Issue