Skip to content

Dependencies

ViewModel Lifecycle

implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.0")

ℹ️ You can use ViewModel without dependencies, but get limited lifetime (the ViewModel will be destroyed every time the composable where it’s declared is recomposed or destroyed). So you have to place the viewModel at MainActivity where it won’t be destroyed or recomposed during runtime.

⚠️ Installing the dependencies will extend the lifetime of the viewModel