Johnjake Talledo
09/12/2022, 5:05 AMdoAnotherCall()
, the viewModel.detailsState
collects in a loop. I mean its emit and collect
in a loop adding delay in doAnotherCall()
does not help. Best Regards.
private suspend fun collectProductList() = withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
viewLifecycleOwner.lifecycleScope.launch {
viewModel.detailsState.collectLatest { state ->
when (state) {
is ItemDetailState.ShowLoader -> binding.progressBar.visible()
is ItemDetailState.HideLoader -> binding.progressBar.gone()
is ItemDetailState.OnSuccess -> handleSubListSuccess(state.list, state.details)
is ItemDetailState.OnFailed -> handleFailure(state.error)
}
}
}
launch {
doAnotherCall()
}
}
list size == counter size
then call doAnotherCall instead of combining it to one scope.Joffrey
09/12/2022, 7:12 AMJohnjake Talledo
09/12/2022, 7:40 AMJoffrey
09/12/2022, 8:30 AM