Skip to content

Commit

Permalink
refactor(ArtistDetailViewModel): 아티스트 상세 비동기 호출 코드 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
SeongHoonC committed Apr 3, 2024
1 parent 6e1be81 commit 9e9c662
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ class ArtistDetailViewModel @Inject constructor(

viewModelScope.launch {
runCatching {
val deferredArtistDetail =
async { artistRepository.loadArtistDetail(id).getOrThrow() }
val deferredFestivals =
async { artistRepository.loadArtistFestivals(id, 10).getOrThrow().toUiState() }
val deferredArtistDetail = async { artistRepository.loadArtistDetail(id) }
val deferredFestivals = async { artistRepository.loadArtistFestivals(id, 10) }
_uiState.value = ArtistDetailUiState.Success(
deferredArtistDetail.await(),
deferredFestivals.await(),
deferredArtistDetail.await().getOrThrow(),
deferredFestivals.await().getOrThrow().toUiState(),
)
}.onFailure {
_uiState.value = ArtistDetailUiState.Error
Expand Down

0 comments on commit 9e9c662

Please sign in to comment.