Last active
June 18, 2023 13:16
-
-
Save Aldikitta/5d952a77c50cbb34959f1e49bd94e01b 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
@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