https://kotlinlang.org logo
Title
r

rajesh

08/17/2021, 9:38 AM
How can we attach ViewModel to specific composable using Hilt? VM should be removed when that composable screen is remvoed.
c

Colton Idle

08/17/2021, 1:28 PM
The docs go over this https://developer.android.com/jetpack/compose/libraries#hilt Is there anything specific you need help with? Basically if you use hilt + VM + compose navigation you will get VM scoped to a destination.
👍 1
i

Ian Lake

08/17/2021, 1:32 PM
You can't scope ViewModels to Composables - see https://issuetracker.google.com/issues/165642391
The only per screen style scoping of ViewModels comes when using Navigation Compose
👍 1