refactor(ApplicationRef): remove all previously deprecated ApplicationRef apis

BREAKING CHANGE: All previously deprecated ApplicationRef apis have been removed.

Please follow the deprecation instructions to migrate your code.
This commit is contained in:
Igor Minar 2016-08-12 15:52:58 -07:00 committed by Vikram Subramanian
parent 44e1b23813
commit f84c3fdc5f
3 changed files with 0 additions and 138 deletions

View File

@ -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<any>) => 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<any>;
/**
* 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<C>(componentFactory: ComponentFactory<C>|Type<C>): ComponentRef<C>;
/**
* Retrieve the application {@link Injector}.
*
* @deprecated inject an {@link Injector} directly where needed or use {@link
* NgModuleRef}.injector.
*/
get injector(): Injector { return <Injector>unimplemented(); };
/**
* Retrieve the application {@link NgZone}.
*
* @deprecated inject {@link NgZone} instead of calling this getter.
*/
get zone(): NgZone { return <NgZone>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<any>[] = [];
private _rootComponentTypes: Type<any>[] = [];
private _changeDetectorRefs: ChangeDetectorRef[] = [];
@ -496,18 +437,6 @@ export class ApplicationRef_ extends ApplicationRef {
{next: () => { this._zone.run(() => { this.tick(); }); }});
}
/**
* @deprecated
*/
registerBootstrapListener(listener: (ref: ComponentRef<any>) => 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<any> { return this._initStatus.donePromise; }
/**
* @deprecated
*/
run(callback: Function): any {
return this._zone.run(
() => _callAndReportToExceptionHandler(this._exceptionHandler, <any>callback));
}
bootstrap<C>(componentOrFactory: ComponentFactory<C>|Type<C>): ComponentRef<C> {
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<any>[] { return this._rootComponentTypes; }
get components(): ComponentRef<any>[] { return this._rootComponents; }

View File

@ -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<any> = 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<any>[] = [];
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<any>[] = [];
const compRef = ref.bootstrap(SomeComponent);
expect(capturedCompRefs).toEqual([compRef]);
}));
});
describe('APP_BOOTSTRAP_LISTENER', () => {
let capturedCompRefs: ComponentRef<any>[];
beforeEach(() => {

View File

@ -147,15 +147,8 @@ export declare class ApplicationModule {
export declare abstract class ApplicationRef {
componentTypes: Type<any>[];
components: ComponentRef<any>[];
/** @deprecated */ injector: Injector;
/** @deprecated */ zone: NgZone;
abstract bootstrap<C>(componentFactory: ComponentFactory<C> | Type<C>): ComponentRef<C>;
/** @deprecated */ abstract dispose(): void;
/** @deprecated */ abstract registerBootstrapListener(listener: (ref: ComponentRef<any>) => void): void;
/** @deprecated */ abstract registerDisposeListener(dispose: () => void): void;
/** @deprecated */ abstract run(callback: Function): any;
abstract tick(): void;
/** @deprecated */ abstract waitForAsyncInitializers(): Promise<any>;
}
/** @experimental */