Reputation: 5734
I want to instantiate a ViewModel with scope of a Composable function.
How can I do this?
I don't want to use navigation-compose
to take advantage of its BackStackEntry
as ViewModelStoreOwner.
Upvotes: 0
Views: 268
Reputation: 606
I faced this issue recently, the only I could solve it by instantiating it manually using remember, not that perfect but it solved my use case for now.
To do the same, you can do something like:
val composeScopeViewModel = remember {
ResidentDetailsViewModel(
// params if any
)
}
Upvotes: 0