diff --git a/modules/angular2/core.dart b/modules/angular2/core.dart index 1b68fa2ebc..6ce0036978 100644 --- a/modules/angular2/core.dart +++ b/modules/angular2/core.dart @@ -1,7 +1,7 @@ library angular2.core; export 'package:angular2/src/core/application_tokens.dart' show APP_COMPONENT; -export 'package:angular2/src/core/application_common.dart' show ApplicationRef; +export 'package:angular2/src/core/application_ref.dart' show ApplicationRef; // Compiler Related Dependencies. export 'package:angular2/src/services/app_root_url.dart' show AppRootUrl; diff --git a/modules/angular2/core.ts b/modules/angular2/core.ts index f8a5b59486..9d50ec8bb0 100644 --- a/modules/angular2/core.ts +++ b/modules/angular2/core.ts @@ -4,8 +4,9 @@ * Define angular core API here. */ export {APP_COMPONENT} from 'angular2/src/core/application_tokens'; -export {ApplicationRef, commonBootstrap as bootstrap} from 'angular2/src/core/application_common'; +export {commonBootstrap as bootstrap} from 'angular2/src/core/application_common'; export {Type} from 'angular2/src/facade/lang'; +export {ApplicationRef} from 'angular2/src/core/application_ref'; // Compiler Related Dependencies. diff --git a/modules/angular2/src/core/application.dart b/modules/angular2/src/core/application.dart index 691fb69d45..5c9a1806f2 100644 --- a/modules/angular2/src/core/application.dart +++ b/modules/angular2/src/core/application.dart @@ -6,8 +6,9 @@ import 'package:angular2/src/reflection/reflection.dart' show reflector; import 'package:angular2/src/reflection/reflection_capabilities.dart' show ReflectionCapabilities; import 'application_common.dart'; +import 'application_ref.dart'; -export 'application_common.dart' show ApplicationRef; +export 'application_ref.dart' show ApplicationRef; /// Starts an application from a root component. This implementation uses /// mirrors. Angular 2 transformer automatically replaces this method with a diff --git a/modules/angular2/src/core/application.ts b/modules/angular2/src/core/application.ts index 17eba2e993..6d4ad8a88d 100644 --- a/modules/angular2/src/core/application.ts +++ b/modules/angular2/src/core/application.ts @@ -1 +1,2 @@ -export {ApplicationRef, commonBootstrap as bootstrap} from './application_common'; +export {commonBootstrap as bootstrap} from './application_common'; +export {ApplicationRef} from './application_ref'; diff --git a/modules/angular2/src/core/application_common.ts b/modules/angular2/src/core/application_common.ts index 8bd5289198..c1a5b57107 100644 --- a/modules/angular2/src/core/application_common.ts +++ b/modules/angular2/src/core/application_common.ts @@ -76,6 +76,7 @@ import {internalView} from 'angular2/src/core/compiler/view_ref'; import {APP_COMPONENT_REF_PROMISE, APP_COMPONENT} from './application_tokens'; import {wtfInit} from '../profile/wtf_init'; import {EXCEPTION_BINDING} from './platform_bindings'; +import {ApplicationRef} from './application_ref'; var _rootInjector: Injector; @@ -337,51 +338,6 @@ export function commonBootstrap( return bootstrapProcess.promise; } -/** - * Represents a Angular's representation of an Application. - * - * `ApplicationRef` represents a running application instance. Use it to retrieve the host - * component, injector, - * or dispose of an application. - */ -export class ApplicationRef { - _hostComponent: ComponentRef; - _injector: Injector; - _hostComponentType: Type; - - /** - * @private - */ - constructor(hostComponent: ComponentRef, hostComponentType: Type, injector: Injector) { - this._hostComponent = hostComponent; - this._injector = injector; - this._hostComponentType = hostComponentType; - } - - /** - * Returns the current {@link ComponentMetadata} type. - */ - get hostComponentType(): Type { return this._hostComponentType; } - - /** - * Returns the current {@link ComponentMetadata} instance. - */ - get hostComponent(): any { return this._hostComponent.instance; } - - /** - * Dispose (un-load) the application. - */ - dispose(): void { - // TODO: We also need to clean up the Zone, ... here! - this._hostComponent.dispose(); - } - - /** - * Returns the root application {@link Injector}. - */ - get injector(): Injector { return this._injector; } -} - function _createAppInjector(appComponentType: Type, bindings: List>, zone: NgZone): Injector { if (isBlank(_rootInjector)) _rootInjector = Injector.resolveAndCreate(_rootBindings); diff --git a/modules/angular2/src/core/application_ref.ts b/modules/angular2/src/core/application_ref.ts new file mode 100644 index 0000000000..9fcefcee50 --- /dev/null +++ b/modules/angular2/src/core/application_ref.ts @@ -0,0 +1,47 @@ +import {ComponentRef} from 'angular2/src/core/compiler/dynamic_component_loader'; +import {Injector} from 'angular2/di'; +import {Type} from 'angular2/src/facade/lang'; +/** + * Represents a Angular's representation of an Application. + * + * `ApplicationRef` represents a running application instance. Use it to retrieve the host + * component, injector, + * or dispose of an application. + */ +export class ApplicationRef { + _hostComponent: ComponentRef; + _injector: Injector; + _hostComponentType: Type; + + /** + * @private + */ + constructor(hostComponent: ComponentRef, hostComponentType: Type, injector: Injector) { + this._hostComponent = hostComponent; + this._injector = injector; + this._hostComponentType = hostComponentType; + } + + /** + * Returns the current {@link ComponentMetadata} type. + */ + get hostComponentType(): Type { return this._hostComponentType; } + + /** + * Returns the current {@link ComponentMetadata} instance. + */ + get hostComponent(): any { return this._hostComponent.instance; } + + /** + * Dispose (un-load) the application. + */ + dispose(): void { + // TODO: We also need to clean up the Zone, ... here! + this._hostComponent.dispose(); + } + + /** + * Returns the root application {@link Injector}. + */ + get injector(): Injector { return this._injector; } +} diff --git a/modules/angular2/src/core/application_static.dart b/modules/angular2/src/core/application_static.dart index 2a76cf75f2..e48cb9f345 100644 --- a/modules/angular2/src/core/application_static.dart +++ b/modules/angular2/src/core/application_static.dart @@ -2,6 +2,7 @@ library angular2.application_static; import 'dart:async'; import 'application_common.dart'; +import 'application_ref.dart'; /// Starts an application from a root component. /// diff --git a/modules/angular2/src/web-workers/worker/application.dart b/modules/angular2/src/web-workers/worker/application.dart index 5bb666cb84..196a6ee7fc 100644 --- a/modules/angular2/src/web-workers/worker/application.dart +++ b/modules/angular2/src/web-workers/worker/application.dart @@ -4,7 +4,7 @@ import "package:angular2/src/web-workers/shared/isolate_message_bus.dart"; import "package:angular2/src/web-workers/worker/application_common.dart" show bootstrapWebWorkerCommon; import "package:angular2/src/facade/async.dart" show Future; -import "package:angular2/src/core/application.dart" show ApplicationRef; +import "package:angular2/src/core/application_ref.dart" show ApplicationRef; import "package:angular2/src/facade/lang.dart" show Type, BaseException; import "dart:isolate"; import "dart:async"; diff --git a/modules/angular2/src/web-workers/worker/application.ts b/modules/angular2/src/web-workers/worker/application.ts index 50c34e0b3f..b15b3335c8 100644 --- a/modules/angular2/src/web-workers/worker/application.ts +++ b/modules/angular2/src/web-workers/worker/application.ts @@ -8,7 +8,7 @@ import {Binding} from "angular2/di"; import {Map} from 'angular2/src/facade/collection'; import {Promise} from 'angular2/src/facade/async'; import {bootstrapWebWorkerCommon} from "angular2/src/web-workers/worker/application_common"; -import {ApplicationRef} from "angular2/src/core/application"; +import {ApplicationRef} from "angular2/src/core/application_ref"; import {Injectable} from "angular2/di"; // TODO(jteplitz602) remove this and compile with lib.webworker.d.ts (#3492) diff --git a/modules/angular2/src/web-workers/worker/application_common.ts b/modules/angular2/src/web-workers/worker/application_common.ts index c52f27d716..3e70625d72 100644 --- a/modules/angular2/src/web-workers/worker/application_common.ts +++ b/modules/angular2/src/web-workers/worker/application_common.ts @@ -55,8 +55,7 @@ import {internalView} from 'angular2/src/core/compiler/view_ref'; import {MessageBrokerFactory} from 'angular2/src/web-workers/worker/broker'; import {MessageBus, MessageBusInterface} from 'angular2/src/web-workers/shared/message_bus'; import {APP_COMPONENT_REF_PROMISE, APP_COMPONENT} from 'angular2/src/core/application_tokens'; -import {ApplicationRef} from 'angular2/src/core/application'; -import {createNgZone} from 'angular2/src/core/application_common'; +import {ApplicationRef} from 'angular2/src/core/application_ref'; import {Serializer} from "angular2/src/web-workers/shared/serializer"; import {ON_WEB_WORKER} from "angular2/src/web-workers/shared/api"; import {RenderProtoViewRefStore} from 'angular2/src/web-workers/shared/render_proto_view_ref_store'; @@ -147,7 +146,7 @@ export function bootstrapWebWorkerCommon( componentInjectableBindings: List> = null): Promise { var bootstrapProcess: PromiseCompleter = PromiseWrapper.completer(); - var zone = createNgZone(); + var zone = new NgZone({enableLongStackTrace: assertionsEnabled()}); zone.run(() => { // TODO(rado): prepopulate template cache, so applications with only // index.html and main.js are possible.