I'm making 2 parallel API calls to request for paging data. I need to combine the result of both API calls upon getting the result and submit the paging data to adapter.
viewLifecycleOwner.lifecycleScope.launchWhenStarted {
val assignedList = async {
assignedTaskViewModel.getPagingTasks(getAssignedTasks)
}
val unscheduledTasksList = async {
assignedTaskViewModel.getUnscheduledChores(getUnscheduledTasks)
}
unscheduledTasksList.await().combine(assignedList.await()) { unschedule, assign ->
Timber.d("combining 2 calls")
//TODO need to show unscheduledTasksList first followed by assignedList
}.collectLatest {
it.map { value ->
Timber.d("paging data = $value")
}
assignedTasksPagingAdapter?.submitData(it)
}
}
is there a way to transform the pagingData so that i can combine the result from 2 API calls and submit to the adapter as single paging data?