Named definitions
Closed this issue · 5 comments
AlexeyPoldeo commented
It will be great to add optional name parameter on registering and getting an object
JulianBissekkou commented
so you are able to get the dependency with that name later on? What is your use case for this feature?
AlexeyPoldeo commented
Yes. Sometimes it's required to inject objects of same class, but different purposes.
Like username and password - both are String.
stefanschaller commented
Okay, we will do it. But you need always the type info. So it will looks like this:
injector.registerDependency<UserService>(dependencyName: "UserService2", (injector) => UserServiceImpl())..
and you get your dependency like this:
injector.getDependency<UserService>(dependencyName: "UserService2");
Are you fine with that?
stefanschaller commented
In version 1.0.5 we added support for named dependencies
AlexeyPoldeo commented
But this is not reflected in Readme...