I’m trying to migrate some code to compose and hav...
# koin
t
I’m trying to migrate some code to compose and have come across a scenario where I have a viewmodel defined in an activity with koin and would like to use this inside of a composable within a composeview in this activity. What would be the easiest way of doing this? My old non-migrated fragment used
by activityViewModel<...>()
and i wondered if there is something similar or what i would need to pass to the
getViewModel
composable to get the same result.
p
but what am currently doing is passing the viewmodel to the composable. i.e.
Copy code
@Composable
fun Greeting(
    helloViewModel: ViewModel
) {
a
The function
koinViewModel()
should be enough to retrieve your VM inside your Composable function