Created
June 14, 2023 10:01
-
-
Save Aldikitta/3a6153c39784eaab8068fc1df0527065 to your computer and use it in GitHub Desktop.
This file contains 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
val visitId = savedStateHandle.get<Int>("visitId") | |
val agentDetail: StateFlow<VisitingDetailUiState>? = | |
visitId?.let { | |
useCase.getDetailAgentVisitFullResponseFlow(id = it).map { visitDetail -> | |
Log.d("MYTAG", ": got exec") | |
when (visitDetail) { | |
is SallyResponseResource.Loading -> { | |
VisitingDetailUiState.Loading | |
} | |
is SallyResponseResource.Success -> { | |
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 | |
) | |
) | |
VisitingDetailUiState.Error(error = visitDetail.exception.toString()) | |
} | |
} | |
}.stateIn( | |
viewModelScope, | |
SharingStarted.WhileSubscribed(5_000), | |
VisitingDetailUiState.Loading | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment