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

Use ViewModel constructor instead of ViewModelProvider #60

Closed
hetbo opened this issue Jan 10, 2020 · 1 comment
Closed

Use ViewModel constructor instead of ViewModelProvider #60

hetbo opened this issue Jan 10, 2020 · 1 comment

Comments

@hetbo
Copy link

hetbo commented Jan 10, 2020

In order to use queries with parameter I didn't find any solution so I tried to create another constructor for both view model class and repository class but I noticed that in CodeLab they don't use view model constructors at all and instead they use view model provider so I changed it and used this : new StoryViewModel(getApplication(),"Fiction"); instead of this: new ViewModelProvider(this).get(StoryViewModel.class);
I don't know if there's anything wrong with this or not. It works fine now, but if it's the way why didn't we use this always? and why do we use view model provider?
Can anyone explain?
Or help me with using queries with parameter.

Thank you.

@hetbo
Copy link
Author

hetbo commented Jan 12, 2020

check the answer here
Also read comments.

@hetbo hetbo closed this as completed Jan 12, 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

1 participant