Skip to content

Solving cyclic dependency #218

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
prijupaul opened this issue Aug 3, 2021 · 3 comments
Closed

Solving cyclic dependency #218

prijupaul opened this issue Aug 3, 2021 · 3 comments

Comments

@prijupaul
Copy link

prijupaul commented Aug 3, 2021

Hi @escamoteur,

First of all, Thank you for the library.

Can you please provide examples of how get_it can solve's cyclic dependencies?

for eg:

GetIt g = GetIt.instance;
g.registerLazySingleton<ServiceA>(() => ServiceA(g.get<ServiceB>()));
g.registerLazySingleton<ServiceA>(() => ServiceB(g.get<ServiceA>()));

If ServiceA is dependent on ServiceB and vice-versa, how do we solve it?

Thanks

@iandis
Copy link

iandis commented Aug 8, 2021

I guess you can create a new class instead that both ServiceA and ServiceB can depend on.

@prijupaul
Copy link
Author

I guess you can create a new class instead that both ServiceA and ServiceB can depend on.

Can you elaborate @iandis. Any code samples pls..?

@iandis
Copy link

iandis commented Aug 14, 2021

@prijupaul I think this stackoverflow discussion may help you.

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

3 participants