-
Notifications
You must be signed in to change notification settings - Fork 724
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
Support @Optional parameters #411
Comments
Thanks for this suggestion. I see your point but I really think that optional dependencies lead to bad code that's why is not available at the moment. Have you encountered a use case in which you need If there is a real use case in which it is needed I will be happy to implement it but I would like to avoid it otherwise. As a side note: When I started to think about |
@remojansen Bad as it might be it is something that in several scenarios is needed. Again, as a library author I would like to inject some values but not always, depending on state and configuration in a dynamic way. For example, a meta wrapper for an express server can be configured to listen to 2 http servers: secured (https) and unsecured (http), both derive from My current solution is to bind both types and set one of the to undefined... About
It's better to keep a consistent API for more verbosity. The
Though I would still add an My 2 cents on this is to be opinionated but not aggressively. |
Sorry for the late reply I wanted to finish other features first. I've been thinking about this and here is my idea of how the API should look like.
|
Hi @shlomiassaf optional dependencies have now been merged into master by #432 and will be available in the 3.0.0-beta.4 release later this week 😉 |
Same as
@Optional
in Angular 2.Regarding the Avoid optional dependencies in Good practices
I couldn't understand if its referring to this idea... if it does, I would like to note that
inversify
should be a library for developers building their applications but also for developers building libraries with the help of inversify.When building a library, injections can be optional, this is a common use case.
I believe
@Optional
should be included, even if in some cases its not recommended.The text was updated successfully, but these errors were encountered: