Skip to content

Suppor for using the same instanceName multiple times for different types #78

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

Closed
Pawelo93 opened this issue May 17, 2020 · 7 comments
Closed

Comments

@Pawelo93
Copy link

Pawelo93 commented May 17, 2020

Hello @escamoteur, I was wondering if it is possible to allow using same instance name for different class types. For example i have two kinds of repositories (different type) and and want to register two of them with name 'local', and all the others repositories with name 'remote'.

Thank you :)

@Pawelo93 Pawelo93 changed the title Suppor for using the same names with Named annotation Suppor for using the same instanceName multiple times for different types May 17, 2020
@escamoteur
Copy link
Collaborator

I think allowing this would make GetIt more complex. You are the first one asking for this. If others want it too I will consider it.

@SAGARSURI
Copy link

SAGARSURI commented May 25, 2020

I agree this is important. In Dagger we have the @nAmed annotation to get two different instances of the same type. Repository class may depends different type of local sources e.g moor or sqflite.

@joanofdart
Copy link

I still fail to see how you need multiple instances of the same repository for the same user o.O

@Pawelo93
Copy link
Author

Pawelo93 commented Aug 13, 2020

I still fail to see how you need multiple instances of the same repository for the same user o.O

I guess you are not using much of abstraction in your codebase. Most complex example is in domain, with multiple use cases on same contract managing this with strings names or class types is time consuming. But there is no other way so far.

Remember that im using injectable, library for generating get_it code, couse in bigger projects it is hard to manually maintain all dependencies.

@escamoteur
Copy link
Collaborator

When I would add this you would be required to pass always the type together the name when accessing your objects

@agubha
Copy link

agubha commented Sep 18, 2020

@Pawelo93 is there any update on this issue?
if you solved it, how did you do it?

@escamoteur
Copy link
Collaborator

Hi, this is now supported in get_it V5.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants