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

27 lines
813 B
Dart

import 'package:angular2/testing_internal.dart' show SpyObject;
import 'package:angular2/core.dart' show Injector, ReflectiveInjector, bind;
import 'package:angular2/src/core/application_ref.dart' show ApplicationRef;
import 'package:angular2/src/core/linker/component_factory.dart'
show ComponentRef;
import 'dart:js';
@proxy
class SpyApplicationRef extends SpyObject implements ApplicationRef {
tick() {}
}
@proxy
class SpyComponentRef extends SpyObject implements ComponentRef {
Injector injector;
SpyComponentRef() {
this.injector = ReflectiveInjector
.resolveAndCreate([bind(ApplicationRef).toClass(SpyApplicationRef)]);
}
}
void callNgProfilerTimeChangeDetection([config]) {
context['ng']['profiler']
.callMethod('timeChangeDetection', config != null ? [config] : []);
}