Skip to content

how can i have two object from one class #100

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
tazik561 opened this issue Aug 1, 2020 · 2 comments
Closed

how can i have two object from one class #100

tazik561 opened this issue Aug 1, 2020 · 2 comments

Comments

@tazik561
Copy link

tazik561 commented Aug 1, 2020

I have a class that provide dio object and i register that in get it like this:
sl.registerLazySingleton(() => NetworkModuleV2.instance.getDio(sl()));
This is provide dio without accept custom header.
Now i want to an instance of Dio but new dio accept custom header.
sl.registerLazySingleton(() => NetworkModuleV2.instance.getDioWithToken(sl()));
Both of two are Dio();

My question is how can i have two object from one class?

@escamoteur
Copy link
Collaborator

In this case use Named Registration if you need to keep them both around all the time. You can pass a name parameter when registering and also pass a name when accessing the object.

@tazik561
Copy link
Author

tazik561 commented Aug 4, 2020

Thanks

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

2 participants