refactor(core): Move LifeCycle functionality into ApplicationRef.
BREAKING CHANGE:
Before: constructor(@Inject(LifeCycle) lifecycle) { lifecycle.tick(); }
After: constructor(@Inject(ApplicationRef) appRef) { appRef.tick(); }
Closes #5008
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import 'package:angular2/testing_internal.dart' show SpyObject;
|
||||
import 'package:angular2/core.dart' show LifeCycle, Injector, bind;
|
||||
import 'package:angular2/core.dart' show Injector, bind;
|
||||
import 'package:angular2/src/core/application_ref.dart' show ApplicationRef;
|
||||
import 'package:angular2/src/core/linker/dynamic_component_loader.dart'
|
||||
show ComponentRef_;
|
||||
import 'dart:js';
|
||||
|
||||
@proxy
|
||||
class SpyLifeCycle extends SpyObject implements LifeCycle {
|
||||
class SpyApplicationRef extends SpyObject implements ApplicationRef {
|
||||
tick() {}
|
||||
noSuchMethod(m) => super.noSuchMethod(m);
|
||||
}
|
||||
|
||||
@@ -15,7 +17,7 @@ class SpyComponentRef extends SpyObject implements ComponentRef_ {
|
||||
|
||||
SpyComponentRef() {
|
||||
this.injector =
|
||||
Injector.resolveAndCreate([bind(LifeCycle).toClass(SpyLifeCycle)]);
|
||||
Injector.resolveAndCreate([bind(ApplicationRef).toClass(SpyApplicationRef)]);
|
||||
}
|
||||
|
||||
noSuchMethod(m) => super.noSuchMethod(m);
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
import {SpyObject} from 'angular2/testing_internal';
|
||||
import {LifeCycle, Injector, provide} from 'angular2/angular2';
|
||||
import {Injector, provide} from 'angular2/angular2';
|
||||
import {ComponentRef} from 'angular2/src/core/linker/dynamic_component_loader';
|
||||
import {global} from 'angular2/src/core/facade/lang';
|
||||
import {ApplicationRef, ApplicationRef_} from 'angular2/src/core/application_ref';
|
||||
|
||||
export class SpyApplicationRef extends SpyObject {
|
||||
constructor() { super(ApplicationRef_); }
|
||||
}
|
||||
|
||||
export class SpyComponentRef extends SpyObject {
|
||||
injector;
|
||||
constructor() {
|
||||
super();
|
||||
this.injector = Injector.resolveAndCreate([provide(LifeCycle, {useValue: {tick: () => {}}})]);
|
||||
this.injector =
|
||||
Injector.resolveAndCreate([provide(ApplicationRef, {useClass: SpyApplicationRef})]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user