-
Notifications
You must be signed in to change notification settings - Fork 726
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
Add Container method to create instances of unbounded classes #505
Comments
Thanks for your feedback 👍 I will review this during the weekend :) |
I have started to work on this I only have one question so far. If you look at the unity example, they resolve I can implement |
Hi @remojansen, that's great news. It didn't occur to me before, I was thinking only in the root class. I guess the plugin should be able to register bindings somehow, probably via an injected service or exporting a declaration. In a previous C# project, we used a custom DI container that would auto-bind any unbound dependency along the way. A global config option would say if it should auto-bind as singleton (we used it as singleton). But something like that may be pushing it too far for a generic container. Bottom line, I think the root class scenario is enough and doesn't force you to make arguable choices. |
This has now been implemented by PR #512 and is available in the inversify@3.3.0 release (should be available over the next hour or so...). Thanks a lot for sharing your feedback with us 👍 |
Amazing. Thanks a lot. |
Feature request to add a Container method capable of create instances of unbounded classes.
Example
In this example,
create
would behave likeget
except for:classes
, not symbols or string identifiers.Use cases
Every time you need to create an instance of an injectable class, but you don't need/want to bind it in the Container. It may apply to the application root.
In my particular use case, I want to load plugins at runtime, these plugins are injectable classes that I want to create and register in a plugin manager, therefore, I don't need to bind them in the Container.
Other injectors:
According to documentation Unity's
Resolve
method seems to behave like that.Environment
Version: 3.1.0
The text was updated successfully, but these errors were encountered: