카테고리 없음
Android compose observeAsState
케이오스
2021. 8. 8. 01:10
관련 영상에는 모두 사용하는데,
어떻게 사용하는지 설명하는 곳은 한 곳도 못 봐서 저처럼 헤매고 있을 사람을 위해 남겨 봅니다.
LiveData.observeAsState()는 androidx.compose.runtime:runtime-livedata:$composeVersion
아티팩트에 포함됩니다.
출처: https://developer.android.com/jetpack/compose/libraries
Compose 및 기타 라이브러리 | Jetpack Compose | Android Developers
Compose에서는 자주 이용하는 라이브러리를 사용할 수 있습니다. 이 섹션에서는 몇 가지 가장 유용한 라이브러리를 통합하는 방법을 설명합니다. ViewModel 아키텍처 구성요소 ViewModel 라이브러리를
developer.android.com
이거 너무 당연한건데 나 혼자 멍청해서 고생한거 아닐까....?
조금 걱정이... ㅠㅠ 😅
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
// -- viewModel
def viewmodel_version = "1.0.0-alpha07"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$viewmodel_version"
// -- LiveData.observeAsState()
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
}