Hey. I want to call a ViewModel function only ONCE in a composable. e.g. viewModel.getMovies() It should not be called on re-composition. How do I achieve this?
m
ms
07/23/2021, 6:20 AM
You can do this in the
init { }
block in the ViewModel itself
j
Jeff
07/23/2021, 6:22 AM
What if I cannot do it there? I share the ViewModel in multiple composables.
m
ms
07/23/2021, 6:26 AM
So to my understanding you are using different instances of ViewModel in different Composables, if so then the moviesList (which you are maintaining) will also be empty right