-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Proposal: allow multiple implementation for the same interface and being able to return all them #33
Comments
I think that it's possible, but can be really slow, because we gonna try to discover all elements type that fits with the given interface. I'm a mantainer in another DI library, later today I gonna check if I can do this there. |
Yeah, that is possible to do |
nice! That would same me quite some manual work. At the end I found a solution where I provide the list of all dependencies, but I then need to list them manually. |
Looks nice, can you share a piece of code that represents it? |
I don't know if have any problem by linking this here, but this is the PR that I made on the DI that I work on |
This is it basically. But of course it would be nicer to be able to register those |
Hi! I am doing some research on DI for Golang and I find this library to be the perfect middle ground of simplicity, efficiency and static stability. There's one missing feature that at the moment doesn't seem to be possible (correct me please if I'm wrong).
There's no way right now to register multiple implementation of the same interface and then being able to retrieve all of them.
I come from Java, where with Springboot, you can inject a
Collection<IService>
.Would that make sense to do it here too?
If you wondering "ok, but how do you handle the case of having 2 implementation of the same interface but your struct only needs one?"
In Springboot in this case you would have an error, because the framework wouldn't know which one to inject.. And we could have the same here too.
The text was updated successfully, but these errors were encountered: