-
-
Save virendersran01/5b67f0dda3f49b36643cf5d653ada408 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