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

why is languagestore, themestore, userstore registered in service_locator #126

Closed
dyardy opened this issue May 11, 2022 · 3 comments
Closed

Comments

@dyardy
Copy link

dyardy commented May 11, 2022

I notice in feature/mvi branch (the latest) that languagestore, themestore, userstore is registered in service_locator AS well as new'd up again in MyApp. This seems like duplication

i.e.
getIt.registerSingleton(LanguageStore(getIt()));
getIt.registerSingleton(ThemeStore(getIt()));
getIt.registerSingleton(UserStore(getIt()));

and also in my_app.dart
final ThemeStore _themeStore = ThemeStore(getIt());
final PostStore _postStore = PostStore(getIt());
final LanguageStore _languageStore = LanguageStore(getIt());
final UserStore _userStore = UserStore(getIt());

@tribal2
Copy link

tribal2 commented Jun 2, 2022

I notice the same because the UserStore builder was being called twice. I changed my code to:

-  final ThemeStore _themeStore = ThemeStore(getIt<Repository>());
-  final PostStore _postStore = PostStore(getIt<Repository>());
-  final LanguageStore _languageStore = LanguageStore(getIt<Repository>());
-  final UserStore _userStore = UserStore(getIt<UserRepository>());

+  final ThemeStore _themeStore = getIt<ThemeStore>();
+  final PostStore _postStore = getIt<PostStore>();
+  final LanguageStore _languageStore = getIt<LanguageStore>();
+  final UserStore _userStore = getIt<UserStore>();

I'm still learning Dart so I don't know if this was made on purpose or if this is a bug 🤷‍♂️

@v1pz3n
Copy link

v1pz3n commented Jan 28, 2023

@tribal2 thanks buddy! I think it's a bug as it double-initializes the store.
I applied your suggestion and it solved the problem of values saved in shared preferences when starting the application.

@zubairehman
Copy link
Owner

zubairehman commented Sep 8, 2024

Apologies for the delay. The latest changes have been merged into the main branch, and the issue should now be resolved. Please pull the latest changes and let us know if you encounter any further issues.

  static Future<void> configureDependencies() async {
    await DataLayerInjection.configureDataLayerInjection();
    await DomainLayerInjection.configureDomainLayerInjection();
    await PresentationLayerInjection.configurePresentationLayerInjection();
  }
}```

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

4 participants