refactor(injector): cleanup
This commit is contained in:
parent
ea22cc4c7a
commit
ab4f86a0cb
|
@ -6,11 +6,11 @@ import 'key.dart' show Key, Dependency;
|
||||||
import 'exceptions.dart' show NoAnnotationError;
|
import 'exceptions.dart' show NoAnnotationError;
|
||||||
|
|
||||||
class Reflector {
|
class Reflector {
|
||||||
factoryFor(Type type) {
|
Function factoryFor(Type type) {
|
||||||
return _generateFactory(type);
|
return _generateFactory(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
convertToFactory(Function factory) {
|
Function convertToFactory(Function factory) {
|
||||||
return (args) => Function.apply(factory, args);
|
return (args) => Function.apply(factory, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class Reflector {
|
||||||
return (args) => create(name, args).reflectee;
|
return (args) => create(name, args).reflectee;
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies(Type type) {
|
List<Dependency> dependencies(Type type) {
|
||||||
ClassMirror classMirror = reflectType(type);
|
ClassMirror classMirror = reflectType(type);
|
||||||
MethodMirror ctor = classMirror.declarations[classMirror.simpleName];
|
MethodMirror ctor = classMirror.declarations[classMirror.simpleName];
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ export function main () {
|
||||||
expect(p).toBeFuture();
|
expect(p).toBeFuture();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a future when if the binding is sync', function() {
|
it('should return a future if the binding is sync', function() {
|
||||||
var injector = new Injector([
|
var injector = new Injector([
|
||||||
SynchronousUserList
|
SynchronousUserList
|
||||||
]);
|
]);
|
||||||
|
@ -42,10 +42,13 @@ export function main () {
|
||||||
expect(p).toBeFuture();
|
expect(p).toBeFuture();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the injector', function() {
|
it('should return the injector', function(done) {
|
||||||
var injector = new Injector([]);
|
var injector = new Injector([]);
|
||||||
var p = injector.asyncGet(Injector);
|
var p = injector.asyncGet(Injector);
|
||||||
expect(p).toBeFuture();
|
p.then(function(injector) {
|
||||||
|
expect(injector).toBe(injector);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a future when instantiating a sync binding ' +
|
it('should return a future when instantiating a sync binding ' +
|
||||||
|
|
|
@ -30,8 +30,8 @@ class ListWrapper {
|
||||||
static last(List list) {
|
static last(List list) {
|
||||||
return list.last;
|
return list.last;
|
||||||
}
|
}
|
||||||
static reversed(List list) {
|
static List reversed(List list) {
|
||||||
return list.reversed;
|
return list.reversed.toList();
|
||||||
}
|
}
|
||||||
static void push(List l, e) { l.add(e); }
|
static void push(List l, e) { l.add(e); }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue