Skip to content

Instantly share code, notes, and snippets.

@Aldikitta
Last active June 18, 2023 13:16
Show Gist options
  • Save Aldikitta/5d952a77c50cbb34959f1e49bd94e01b to your computer and use it in GitHub Desktop.
Save Aldikitta/5d952a77c50cbb34959f1e49bd94e01b to your computer and use it in GitHub Desktop.
@Composable
Fun stateFullScreen(){
// lets say we done handle our viewmodels
Val uiState by viewmodel.uiState.collectWithLifeCycle()
LaunchedEffect() {
viewmodel.getAgentVisitDetailFullResponse()
}
stateLessScreen(
uiState = uiState,
viewModel = viewmodel
}
}
@Composable
Fun stateLessScreen(
uiState: VisitingDetailUiState,
viewModel: ViewModel
) {
When (uiState) {
Is VisitingUIState.Success -> {
// HANDLE SUCCESS EVENT
}
Is VisitingUIState.Loading -> {
// HANDLE LOADING EVENT
}
Is VisitingUIState.Error -> {
viewModel.eventFlow.collectLatest {
when (it) {
is VisitingUiEvent.ShowErrorMessageStatic -> {
Timber.tag("MYTAG").d("observeVisitDetail: %s", it.staticError)
Timber.tag("MYTAG").d("observeVisitDetail: %s", it.dynamicError)
Timber.tag("MYTAG").d("observeVisitDetail: %s", it.errorCode)
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment