I have Multiple screens as Composable like HomeScreen, DashboardScreen, etc and all of them has it's own ViewModel e.g HomeViewModel
and I'm using ViewModel as
Copy code
val viewModel: HomeViewModel = viewModel()
in each screen, Do these ViewModels remain in memory all the time because I'm using a Single Activity? and I'm not using Navigation Component
a
allan.conda
01/28/2021, 8:52 AM
it lives as long as
Copy code
AmbientViewModelStoreOwner.current
allan.conda
01/28/2021, 8:57 AM
If you’re not using navigation component, it’s probably scoped to the Activity or Fragment.
You can check that value to make sure