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

Mehdi Haghgoo

11/20/2021, 8:47 PM
Which artifact for livedata integration? androidx.compose.runtime:runtime-livedata or androidx.lifecycle:lifecycle-viewmodel-compose?
i

Ian Lake

11/21/2021, 12:08 AM
androidx.compose.runtime:runtime-livedata
is what has
observeAsState
.
viewmodel-compose
only has APIs for dealing specifically with ViewModels
❤️ 1
m

Mehdi Haghgoo

11/21/2021, 1:36 AM
I used to add only the former and the code worked. For example, I could use ViewModels and as you said, observeAsState. Has that changed? Do I need to add the latter to projects too?
i

Ian Lake

11/21/2021, 2:50 AM
There's no
androidx.compose
artifact that gives you ViewModel support, but other artifacts, like Navigation Compose, do pull in
viewmodel-compose
as a transitive dependency, which would make it available to your code as well
❤️ 1