Closed amcdnl closed 8 years ago
Hi guys! using decorators and reflect-metadata is in my plans :+1: Thanks for your feedback and I promise I will do something about it as soon as I can :smile:
Fixed by #34 ? @remojansen
Hi @amcdnl I'm closing this issue because as @Jameskmonger said above #34 has added support for the @Inject
decorator:
You should be able to do the following:
import { Inject } from "inversify";
@Inject("FooInterface", "BarInterface")
class FooBar implements FooBarInterface {
public foo : FooInterface;
public bar : BarInterface;
public log(){
console.log("foobar");
}
constructor(foo : FooInterface, bar : BarInterface) {
this.foo = foo;
this.bar = bar;
}
}
var FooBar = (function () {
function FooBar(FooInterface, BarInterface) {
this.foo = FooInterface;
this.bar = BarInterface;
}
FooBar.prototype.log = function () {
console.log("foobar");
};
return Inject("FooInterface", "BarInterface")(FooBar);
})();
Also, we have plans to use the reflec-metada API in 2.0 but we have not used for the moment because we don't really need it and we would need to use fallback and that would increase the size of InversifyJS.
Thanks for your feedback :+1:
Just to clarify, your not planning to support ES-next decorators?
Yes we are going to use the ES7 Reflect API and some decorators. The decorators that I have in mine can be preview at https://github.com/inversify/InversifyJS/tree/2.0/source/decorators
One of them (@tagged
) allows the users to add metadata that can be used in constrained bindings. Under the hood this decorators will use the Reflect
to read and write the metadata. This is really similar to @Reflect.metadata(metadataKey, metadataValue)
from the project that you shared (ReflectDecorators).
:) ... eta on release?
Some ES7 Decorator examples would be awesome!
It would also be nice to see how u could take advantage of meta-data proposal too - https://github.com/rbuckton/ReflectDecorators