Skip to content

Locating instance variables #95

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
Bryanx opened this issue Jul 17, 2020 · 2 comments
Closed

Locating instance variables #95

Bryanx opened this issue Jul 17, 2020 · 2 comments

Comments

@Bryanx
Copy link
Contributor

Bryanx commented Jul 17, 2020

I have a some nested stores and would like to locate them all individually. What would be the best way to do this? At the moment I'm doing it like this:

// store structure:
class MainStore {
  var reminderStore = ReminderStore();
}

class ReminderStore {
  var taskStore = TaskStore();
}

// registering the instances:
var mainStore = new MainStore();
GetIt.instance.registerSingleton<MainStore>(mainStore);
GetIt.instance.registerSingleton<ReminderStore>(mainStore.reminderStore);
GetIt.instance.registerSingleton<TaskStore>(mainStore.reminderStore.taskStore);
@escamoteur
Copy link
Collaborator

I think it's perfectly fine to do it that way- But if you have them registered directly this way, Why do you nest them at all?

@Bryanx
Copy link
Contributor Author

Bryanx commented Jul 26, 2020

You were right, it was possible to remove nesting entirely. Thanks :)

@Bryanx Bryanx closed this as completed Jul 26, 2020
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