Tobias Bosch 0a7d10ba55 refactor(core): separate reflective injector from Injector interface
BREAKING CHANGE:
- Injector was renamed into `ReflectiveInjector`,
  as `Injector` is only an abstract class with one method on it
- `Injector.getOptional()` was changed into `Injector.get(token, notFoundValue)`
  to make implementing injectors simpler
- `ViewContainerRef.createComponent` now takes an `Injector`
  instead of `ResolvedProviders`. If a reflective injector
  should be used, create one before calling this method.
  (e.g. via `ReflectiveInjector.resolveAndCreate(…)`.
2016-04-20 11:28:13 -07:00

22 lines
692 B
TypeScript

import {SpyObject} from 'angular2/testing_internal';
import {ReflectiveInjector, provide} from 'angular2/core';
import {global} from 'angular2/src/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 = ReflectiveInjector.resolveAndCreate(
[provide(ApplicationRef, {useClass: SpyApplicationRef})]);
}
}
export function callNgProfilerTimeChangeDetection(config?): void {
(<any>global).ng.profiler.timeChangeDetection(config);
}