-
Notifications
You must be signed in to change notification settings - Fork 77
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
How to get access to other scoped models in a scoped model file? #75
Comments
I have played around with different options doing the same thing. Here's what I decided to do, but I'd like feedback on if its appropriate. I have a global UserModel and a global AppModel. Since my AppModel wants to make changes if my UserModel changes, in the constructor of AppModel I do this.
|
Do you make use of a single model to pass around (e.g. a MainModel)? The way I use it is the following:
Like this you can use all variables from these models in one model. Pass the MainModel model everywhere and access a var from the UserModel by e.g. calling widget.model.user.name. To access the model in e.g. your usermodel, pass the mainModel to the function in the userModel:
|
Hi! I want to get access to _authenticatedUser which is in UserModel from ProductsModel.
What is the most effective way to get it?
I guess i can use ScopedModel.of and pass it as an argument from View. But i don't feel like this is ideal.
Or is it okay to use DI library like get_it in a model file? (UserModel _userModel = locator< UserModel >();)
If it's okay, whether i use singleton or not when registering model using DI library makes any difference?
I guess i have to use singleton to keep states in a model.
The text was updated successfully, but these errors were encountered: