-
-
Save virendersran01/4e7aaba1df8d7e696b53b3b897e4e550 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
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