parent
a1f4060126
commit
709c3ca6b5
|
@ -73,7 +73,7 @@ function _injectorBindings(appComponentType): List<Binding> {
|
|||
[appViewToken]),
|
||||
bind(appComponentType).toFactory((rootView) => rootView.elementInjectors[0].getComponent(),
|
||||
[appViewToken]),
|
||||
bind(LifeCycle).toFactory(() => new LifeCycle(null, assertionsEnabled()),[]),
|
||||
bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle(exceptionHandler, null, assertionsEnabled()),[ExceptionHandler]),
|
||||
bind(EventManager).toFactory((zone) => {
|
||||
var plugins = [new HammerGesturesPlugin()];
|
||||
return new EventManager(plugins, zone);
|
||||
|
|
|
@ -1,32 +1,31 @@
|
|||
import {FIELD, print} from 'angular2/src/facade/lang';
|
||||
import {ChangeDetector} from 'angular2/change_detection';
|
||||
import {VmTurnZone} from 'angular2/src/core/zone/vm_turn_zone';
|
||||
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
|
||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {isPresent} from 'angular2/src/facade/lang';
|
||||
|
||||
export class LifeCycle {
|
||||
_errorHandler;
|
||||
_changeDetector:ChangeDetector;
|
||||
_enforceNoNewChanges:boolean;
|
||||
|
||||
constructor(changeDetector:ChangeDetector = null, enforceNoNewChanges:boolean = false) {
|
||||
constructor(exceptionHandler:ExceptionHandler, changeDetector:ChangeDetector = null, enforceNoNewChanges:boolean = false) {
|
||||
this._errorHandler = (exception, stackTrace) => {
|
||||
exceptionHandler.call(exception, stackTrace);
|
||||
throw exception;
|
||||
};
|
||||
this._changeDetector = changeDetector; // may be null when instantiated from application bootstrap
|
||||
this._enforceNoNewChanges = enforceNoNewChanges;
|
||||
}
|
||||
|
||||
registerWith(zone:VmTurnZone, changeDetector:ChangeDetector = null) {
|
||||
// temporary error handler, we should inject one
|
||||
var errorHandler = (exception, stackTrace) => {
|
||||
var longStackTrace = ListWrapper.join(stackTrace, "\n\n-----async gap-----\n");
|
||||
print(`${exception}\n\n${longStackTrace}`);
|
||||
throw exception;
|
||||
};
|
||||
|
||||
if (isPresent(changeDetector)) {
|
||||
this._changeDetector=changeDetector;
|
||||
}
|
||||
|
||||
zone.initCallbacks({
|
||||
onErrorHandler: errorHandler,
|
||||
onErrorHandler: this._errorHandler,
|
||||
onTurnDone: () => this.tick()
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import {isPresent, Type} from 'angular2/src/facade/lang';
|
|||
|
||||
import {Injector} from 'angular2/di';
|
||||
import {Lexer, Parser, ChangeDetector, dynamicChangeDetection} from 'angular2/change_detection';
|
||||
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
|
||||
|
||||
import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
|
||||
import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
|
||||
|
@ -53,7 +54,7 @@ export function main() {
|
|||
compiler.compile(MyComp)
|
||||
.then(createView)
|
||||
.then((view) => {
|
||||
var lc = new LifeCycle(view.changeDetector, false);
|
||||
var lc = new LifeCycle(new ExceptionHandler(), view.changeDetector, false);
|
||||
assertions(view, lc);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import {MapWrapper} from 'angular2/src/facade/collection';
|
|||
|
||||
import {Parser, Lexer, ChangeDetector, ChangeDetection}
|
||||
from 'angular2/change_detection';
|
||||
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
|
||||
import {
|
||||
bootstrap, Component, Viewport, Template, ViewContainer, Compiler, onChange
|
||||
} from 'angular2/angular2';
|
||||
|
@ -225,9 +226,15 @@ export function setupReflectorForAngular() {
|
|||
'annotations': []
|
||||
});
|
||||
|
||||
reflector.registerType(ExceptionHandler, {
|
||||
"factory": () => new ExceptionHandler(),
|
||||
"parameters": [],
|
||||
"annotations": []
|
||||
});
|
||||
|
||||
reflector.registerType(LifeCycle, {
|
||||
"factory": (cd) => new LifeCycle(cd),
|
||||
"parameters": [[ChangeDetector]],
|
||||
"factory": (exHandler, cd) => new LifeCycle(exHandler, cd),
|
||||
"parameters": [[ExceptionHandler, ChangeDetector]],
|
||||
"annotations": []
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {Parser, Lexer, ChangeDetector, ChangeDetection, jitChangeDetection}
|
||||
from 'angular2/change_detection';
|
||||
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
|
||||
|
||||
import {bootstrap, Component, Viewport, Template, ViewContainer, Compiler} from 'angular2/angular2';
|
||||
|
||||
|
@ -114,9 +115,15 @@ function setupReflector() {
|
|||
'annotations': []
|
||||
});
|
||||
|
||||
reflector.registerType(ExceptionHandler, {
|
||||
"factory": () => new ExceptionHandler(),
|
||||
"parameters": [],
|
||||
"annotations": []
|
||||
});
|
||||
|
||||
reflector.registerType(LifeCycle, {
|
||||
"factory": (cd) => new LifeCycle(cd),
|
||||
"parameters": [[ChangeDetector]],
|
||||
"factory": (exHandler, cd) => new LifeCycle(exHandler, cd),
|
||||
"parameters": [[ExceptionHandler, ChangeDetector]],
|
||||
"annotations": []
|
||||
});
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import * as app from './index_common';
|
|||
|
||||
import {Component, Decorator, Template, NgElement} from 'angular2/angular2';
|
||||
import {Lexer, Parser, ChangeDetection, ChangeDetector} from 'angular2/change_detection';
|
||||
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
|
||||
import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle';
|
||||
|
||||
import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
|
||||
|
@ -94,9 +95,15 @@ function setup() {
|
|||
"annotations": []
|
||||
});
|
||||
|
||||
reflector.registerType(ExceptionHandler, {
|
||||
"factory": () => new ExceptionHandler(),
|
||||
"parameters": [],
|
||||
"annotations": []
|
||||
});
|
||||
|
||||
reflector.registerType(LifeCycle, {
|
||||
"factory": (cd) => new LifeCycle(cd),
|
||||
"parameters": [[ChangeDetector]],
|
||||
"factory": (exHandler, cd) => new LifeCycle(exHandler, cd),
|
||||
"parameters": [[ExceptionHandler, ChangeDetector]],
|
||||
"annotations": []
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue