diff --git a/modules/@angular/core/src/application_ref.ts b/modules/@angular/core/src/application_ref.ts index af637e81d7..cd94c2fb0c 100644 --- a/modules/@angular/core/src/application_ref.ts +++ b/modules/@angular/core/src/application_ref.ts @@ -373,38 +373,6 @@ export class PlatformRef_ extends PlatformRef { * @experimental APIs related to application bootstrap are currently under review. */ export abstract class ApplicationRef { - /** - * Register a listener to be called each time `bootstrap()` is called to bootstrap - * a new root component. - * - * @deprecated Provide a callback via a multi provider for {@link APP_BOOTSTRAP_LISTENER} - * instead. - */ - abstract registerBootstrapListener(listener: (ref: ComponentRef) => void): void; - - /** - * Register a listener to be called when the application is disposed. - * - * @deprecated Use `ngOnDestroy` lifecycle hook or {@link NgModuleRef}.onDestroy. - */ - abstract registerDisposeListener(dispose: () => void): void; - - /** - * Returns a promise that resolves when all asynchronous application initializers - * are done. - * - * @deprecated Use the {@link ApplicationInitStatus} class instead. - */ - abstract waitForAsyncInitializers(): Promise; - - /** - * Runs the given callback in the zone and returns the result of the callback. - * Exceptions will be forwarded to the ExceptionHandler and rethrown. - * - * @deprecated Use {@link NgZone}.run instead. - */ - abstract run(callback: Function): any; - /** * Bootstrap a new component at the root level of the application. * @@ -419,29 +387,6 @@ export abstract class ApplicationRef { */ abstract bootstrap(componentFactory: ComponentFactory|Type): ComponentRef; - /** - * Retrieve the application {@link Injector}. - * - * @deprecated inject an {@link Injector} directly where needed or use {@link - * NgModuleRef}.injector. - */ - get injector(): Injector { return unimplemented(); }; - - /** - * Retrieve the application {@link NgZone}. - * - * @deprecated inject {@link NgZone} instead of calling this getter. - */ - get zone(): NgZone { return unimplemented(); }; - - /** - * Dispose of this application and all of its components. - * - * @deprecated Destroy the module that was created during bootstrap instead by calling - * {@link NgModuleRef}.destroy. - */ - abstract dispose(): void; - /** * Invoke this method to explicitly process change detection and its side-effects. * @@ -472,10 +417,6 @@ export class ApplicationRef_ extends ApplicationRef { static _tickScope: WtfScopeFn = wtfCreateScope('ApplicationRef#tick()'); private _bootstrapListeners: Function[] = []; - /** - * @deprecated - */ - private _disposeListeners: Function[] = []; private _rootComponents: ComponentRef[] = []; private _rootComponentTypes: Type[] = []; private _changeDetectorRefs: ChangeDetectorRef[] = []; @@ -496,18 +437,6 @@ export class ApplicationRef_ extends ApplicationRef { {next: () => { this._zone.run(() => { this.tick(); }); }}); } - /** - * @deprecated - */ - registerBootstrapListener(listener: (ref: ComponentRef) => void): void { - this._bootstrapListeners.push(listener); - } - - /** - * @deprecated - */ - registerDisposeListener(dispose: () => void): void { this._disposeListeners.push(dispose); } - registerChangeDetector(changeDetector: ChangeDetectorRef): void { this._changeDetectorRefs.push(changeDetector); } @@ -516,19 +445,6 @@ export class ApplicationRef_ extends ApplicationRef { ListWrapper.remove(this._changeDetectorRefs, changeDetector); } - /** - * @deprecated - */ - waitForAsyncInitializers(): Promise { return this._initStatus.donePromise; } - - /** - * @deprecated - */ - run(callback: Function): any { - return this._zone.run( - () => _callAndReportToExceptionHandler(this._exceptionHandler, callback)); - } - bootstrap(componentOrFactory: ComponentFactory|Type): ComponentRef { if (!this._initStatus.done) { throw new BaseException( @@ -578,16 +494,6 @@ export class ApplicationRef_ extends ApplicationRef { ListWrapper.remove(this._rootComponents, componentRef); } - /** - * @deprecated - */ - get injector(): Injector { return this._injector; } - - /** - * @deprecated - */ - get zone(): NgZone { return this._zone; } - tick(): void { if (this._runningTick) { throw new BaseException('ApplicationRef.tick is called recursively'); @@ -609,14 +515,8 @@ export class ApplicationRef_ extends ApplicationRef { ngOnDestroy() { // TODO(alxhub): Dispose of the NgZone. ListWrapper.clone(this._rootComponents).forEach((ref) => ref.destroy()); - this._disposeListeners.forEach((dispose) => dispose()); } - /** - * @deprecated - */ - dispose(): void { this.ngOnDestroy(); } - get componentTypes(): Type[] { return this._rootComponentTypes; } get components(): ComponentRef[] { return this._rootComponents; } diff --git a/modules/@angular/core/test/application_ref_spec.ts b/modules/@angular/core/test/application_ref_spec.ts index 28142c76c4..cd5aa32741 100644 --- a/modules/@angular/core/test/application_ref_spec.ts +++ b/modules/@angular/core/test/application_ref_spec.ts @@ -82,37 +82,6 @@ export function main() { } })); - describe('run', () => { - it('should rethrow errors even if the exceptionHandler is not rethrowing', - inject([ApplicationRef], (ref: ApplicationRef_) => { - expect(() => ref.run(() => { throw new BaseException('Test'); })).toThrowError('Test'); - })); - - it('should return a promise with rejected errors even if the exceptionHandler is not rethrowing', - async(inject([ApplicationRef], (ref: ApplicationRef_) => { - var promise: Promise = ref.run(() => Promise.reject('Test')); - promise.then(() => expect(false).toBe(true), (e) => { expect(e).toEqual('Test'); }); - }))); - }); - - describe('registerBootstrapListener', () => { - it('should be called when a component is bootstrapped', - inject([ApplicationRef], (ref: ApplicationRef_) => { - const capturedCompRefs: ComponentRef[] = []; - ref.registerBootstrapListener((compRef) => capturedCompRefs.push(compRef)); - const compRef = ref.bootstrap(SomeComponent); - expect(capturedCompRefs).toEqual([compRef]); - })); - - it('should be called immediately when a component was bootstrapped before', - inject([ApplicationRef], (ref: ApplicationRef_) => { - ref.registerBootstrapListener((compRef) => capturedCompRefs.push(compRef)); - const capturedCompRefs: ComponentRef[] = []; - const compRef = ref.bootstrap(SomeComponent); - expect(capturedCompRefs).toEqual([compRef]); - })); - }); - describe('APP_BOOTSTRAP_LISTENER', () => { let capturedCompRefs: ComponentRef[]; beforeEach(() => { diff --git a/tools/public_api_guard/core/index.d.ts b/tools/public_api_guard/core/index.d.ts index e81fd39f52..6f7026b850 100644 --- a/tools/public_api_guard/core/index.d.ts +++ b/tools/public_api_guard/core/index.d.ts @@ -147,15 +147,8 @@ export declare class ApplicationModule { export declare abstract class ApplicationRef { componentTypes: Type[]; components: ComponentRef[]; - /** @deprecated */ injector: Injector; - /** @deprecated */ zone: NgZone; abstract bootstrap(componentFactory: ComponentFactory | Type): ComponentRef; - /** @deprecated */ abstract dispose(): void; - /** @deprecated */ abstract registerBootstrapListener(listener: (ref: ComponentRef) => void): void; - /** @deprecated */ abstract registerDisposeListener(dispose: () => void): void; - /** @deprecated */ abstract run(callback: Function): any; abstract tick(): void; - /** @deprecated */ abstract waitForAsyncInitializers(): Promise; } /** @experimental */