Last active
June 18, 2023 13:17
-
-
Save Aldikitta/f23182aea13f774c83c81d46aa72a778 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
override fun onViewCreated() { | |
viewModel.getAgentVisitDetailFullResponse() | |
observeVisitDetail() | |
} | |
private fun observeVisitDetail() { | |
viewLifecycleOwner.lifecycleScope.launch { | |
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) { | |
viewModel.uiStateDetail.collect { visitingUiState -> | |
when (visitingUiState) { | |
is VisitingDetailUiState.Success -> { | |
// HANDLE SUCCESS EVENT | |
} | |
is VisitingDetailUiState.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) | |
} | |
} | |
} | |
} | |
is VisitingDetailUiState.Loading -> { | |
// HANDLE LOADING EVENT | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment