in documentation i can see we can specify owner and scope, but not sure where exactly we should add it
You can specify the
owner
& `scope`:
inline fun <_reified_ T : ViewModel> getViewModel(
qualifier: Qualifier? =
null,
owner: ViewModelOwner = getComposeViewModelOwner(),
scope: Scope = GlobalContext.get().scopeRegistry.rootScope,
noinline parameters: ParametersDefinition? =
null,
)
Where ViewModelOwner can be used to pass a StoreOwner (like navigation):
@Composable
fun getComposeViewModelOwner(): ViewModelOwner {
return ViewModelOwner.from(
LocalViewModelStoreOwner.current!!,
LocalSavedStateRegistryOwner.current
)
}