From da184a5c13eb149c55a53dbfad0ae49f493b34a9 Mon Sep 17 00:00:00 2001 From: vrexpert Date: Wed, 3 Apr 2024 17:37:00 +0900 Subject: [PATCH] =?UTF-8?q?fest(ArtistDetailViewModel):=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=EB=A5=BC=20=EB=B9=84=EB=8F=99=EA=B8=B0?= =?UTF-8?q?=EB=A1=9C=20=EC=9A=94=EC=B2=AD=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/artistdetail/ArtistDetailViewModel.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/ArtistDetailViewModel.kt b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/ArtistDetailViewModel.kt index 503779bd7..2ff4132cc 100644 --- a/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/ArtistDetailViewModel.kt +++ b/android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/artistdetail/ArtistDetailViewModel.kt @@ -8,6 +8,7 @@ import com.festago.festago.presentation.ui.artistdetail.uistate.ArtistDetailUiSt import com.festago.festago.presentation.ui.artistdetail.uistate.ArtistUiState import com.festago.festago.presentation.ui.artistdetail.uistate.FestivalItemUiState import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.async import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow @@ -33,9 +34,13 @@ class ArtistDetailViewModel @Inject constructor( viewModelScope.launch { runCatching { + val deferredArtistDetail = + async { artistRepository.loadArtistDetail(id).getOrThrow() } + val deferredFestivals = + async { artistRepository.loadArtistFestivals(id, 10).getOrThrow().toUiState() } _uiState.value = ArtistDetailUiState.Success( - artistRepository.loadArtistDetail(id).getOrThrow(), - artistRepository.loadArtistFestivals(id, 20).getOrThrow().toUiState(), + deferredArtistDetail.await(), + deferredFestivals.await(), ) }.onFailure { _uiState.value = ArtistDetailUiState.Error