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