refactor(core): use ngOnDestroy in providers

Note about the addition of `beforeEach(fakeAsync(inject(…))))` in some tests:
`ApplicationRef` is now using `ngOnDestroy` and there is eager,
including all of its dependencies which contain `NgZone`.
The additional `fakeAsync` in `beforeEach` ensures that `NgZone`
uses the fake async zone as parent, and not the root zone.

BREAKING CHANGE (via deprecations):
- `ApplicationRef.dispose` is deprecated. Destroy the module that was
   created during bootstrap instead by calling `NgModuleRef.destroy`.
- `AplicationRef.registerDisposeListener` is deprecated.
   Use the `ngOnDestroy` lifecycle hook for providers or
   `NgModuleRef.onDestroy` instead.
- `disposePlatform` is deprecated. Use `destroyPlatform` instead.
- `PlatformRef.dipose()` is deprecated. Use `PlatformRef.destroy()`
   instead.
- `PlatformRef.registerDisposeListener` is deprecated. Use
  `PlatformRef.onDestroy` instead.
- `PlaformRef.diposed` is deprecated. Use `PlatformRef.destroyed`
  instead.
This commit is contained in:
Tobias Bosch
2016-08-02 02:32:27 -07:00
parent ecdaded25f
commit 8e6091de6c
12 changed files with 150 additions and 106 deletions

View File

@ -39,7 +39,7 @@ export function main() {
beforeEach(
() => { TestBed.configureCompiler({providers: [{provide: XHR, useClass: SpyXHR}]}); });
beforeEach(inject(
beforeEach(fakeAsync(inject(
[Compiler, TestComponentBuilder, XHR, DirectiveResolver, Injector],
(_compiler: Compiler, _tcb: TestComponentBuilder, _xhr: SpyXHR,
_dirResolver: MockDirectiveResolver, _injector: Injector) => {
@ -48,7 +48,7 @@ export function main() {
xhr = _xhr;
dirResolver = _dirResolver;
injector = _injector;
}));
})));
describe('clearCacheFor', () => {
it('should support changing the content of a template referenced via templateUrl',