Created
June 14, 2023 09:59
-
-
Save Aldikitta/f9bc45e89c733ab9056abf2376c4b146 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun getAgentVisitDetailFullResponseFlow() { | |
val visitId = savedStateHandle.get<Int>("visitId") | |
viewModelScope.launch { | |
if (visitId != null) { | |
useCase.getDetailAgentVisitFullResponseFlow(id = visitId) | |
.collectLatest { visitDetail -> | |
when (visitDetail) { | |
is SallyResponseResource.Loading -> { | |
_uiStateDetail.value = VisitingDetailUiState.Loading | |
} | |
is SallyResponseResource.Success -> { | |
_uiStateDetail.value = | |
VisitingDetailUiState.Success(visitDetail.data.data) | |
} | |
is SallyResponseResource.Error -> { | |
_eventFlow.emit( | |
VisitingUiEvent.ShowErrorMessageStatic( | |
staticError = visitDetail.exception.message, | |
dynamicError = visitDetail.exception.cause?.message.toString(), | |
errorCode = visitDetail.errorCode | |
) | |
) | |
_uiStateDetail.value = | |
VisitingDetailUiState.Error(error = visitDetail.exception.toString()) | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment