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

ViewModels should be able to be scoped #194

Open
osrl opened this issue Aug 30, 2023 · 4 comments
Open

ViewModels should be able to be scoped #194

osrl opened this issue Aug 30, 2023 · 4 comments

Comments

@osrl
Copy link
Contributor

osrl commented Aug 30, 2023

Android has scoped ViewModels with navGraphViewModels as shown in here. Since we don't have navGraphViewModels in voyager, we can't use scoped states with ViewModels. (Although it may be possible using AndroidScreenLifecycleOwner. But I couldn't figure out how)
Same should apply to ScreenModel too.

@programadorthi
Copy link
Collaborator

@osrl Checkout pull request #217

@osrl
Copy link
Contributor Author

osrl commented Sep 25, 2023

will do. thank you very much.

@DevSrSouza
Copy link
Collaborator

I think my answer here apply to this issue as well: #168 (comment)

you could also try this to have scoped viewmodels: viewModel<YourScopedViewModel>(viewModelStoreOwner = LocalContext.context.unwrapActivity)

@osrl
Copy link
Contributor Author

osrl commented Nov 6, 2023

I'm currently using this but my app is single activity and this makes it scoped to the entire app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants