https://kotlinlang.org logo
#compose
Title
# compose
r

Rodri Represa

11/17/2020, 6:15 PM
Does anyone knows why my ViewModel always restart my
var image by mutableStateOf
value every time I get the viewmodel (
val viewModel = getViewModel<MainViewModel>()
) in a composable function? I'm using koin to inject it.
Also I realised that my viewmodel always executive the
init{}
when I get it in a
@Composable
v

Vivek Sharma

11/17/2020, 6:16 PM
maybe recomposing doing that
r

Rodri Represa

11/17/2020, 6:23 PM
yeah, I think I should pass a parameter to the
@Composable
and then, when I get the viewmodel refresh my data
v

Vivek Sharma

11/17/2020, 6:26 PM
yes, pass viewmodel in params
g

gildor

11/17/2020, 11:21 PM
Looks that you need
remember
2 Views