-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to Use Inversify? #131
Comments
Ok I figure I can pass the Inversify container to my custom ServiceFactory. What I've noticed is that for the following handler: public create(serviceClass: any, context: ServiceContext) {
console.log('>>> CREATE SERVICE FACTORY >>>');
return return this.container.get(serviceClass);
} serviceClass is a handle to the Controller class, not to the injected service. For example, if I'm inject a service into MyController called MyService, the create() method is getting MyController. So when I try and use the Inversify container to get the serviceClass, it obviously doesn't know anything about the controller and I'm given this error:
How do I get the handle for the MyService property so I can get the property rather than the controller? I really wish that there was some sort of example in the documentation or test code or something. Thank you! |
Hi - Were you able to get it working? |
I see references to creating our own ServiceFactory for using other IoC containers like Inversify. I've been working with this for several hours now and can not figure out how it is supposed to work with Inversify. I am successfully binding a service with Inversify that I can use outside of a typescript-rest controller, and I've implemented the following custom class:
And I correctly inject it with:
I see that the typescript-rest-ioc does the following:
However, for Inversify, this is what we're provided:
Which takes an interfaces.ServiceIdentifier.
I'm sure I'm missing something simple, but hoping I can get some quick guidance about how to complete my ServiceFactory since I've seen several places claiming that Inversify is usable, but I keep getting undefined when I inject into the controller.
Thanks!
The text was updated successfully, but these errors were encountered: