Skip to content
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

Where to initialize serviceLocator in clean architecture? #64

Closed
manjrekarom opened this issue Apr 7, 2020 · 1 comment
Closed

Where to initialize serviceLocator in clean architecture? #64

manjrekarom opened this issue Apr 7, 2020 · 1 comment

Comments

@manjrekarom
Copy link

I am following clean architecture tutorial from Resocoder https://resocoder.com/flutter-clean-architecture-tdd/ and well that is how I got introduced to Get_it.

I have three questions to ask:

  1. How many service locators should I have in an application?
  2. Should I initialize the ServiceLocator in main?
  3. How do I manage dependencies properly?

In the tutorial it is mentioned that I should have a separate injection_container.dart for each feature. The problem is that some of these features share dependencies due to which if I initialize them in the wrong order, Get_it throws an error. Also I am initializing all this together in main, is there a better way to do this?

If you could point me to a resource where I can read about this further that will be great.

@escamoteur
Copy link
Collaborator

Hi,
unless you have a good reason, you only should use one service locator

  1. I typically do it in main.
  2. Have you seen the new startup synchronization feature of GetIt? Check out: https://www.burkharts.net/apps/blog/lets-get-this-party-started-startup-orchestration-with-getit/

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