I'm working on combining multiple `PagingData` flo...
# android
n
I'm working on combining multiple
PagingData
flows into a single list. Specifically, I need to call the paging flow twice with different requests and then merge the results into one unified list. Currently, I have the following code to generate multiple
PagingData
flows:
Copy code
val pagingDataFlows = selectedLineIds.map { lineId ->
    val params = mapOf(
        "lines" to lineId.toString(),
        "status" to filters.status.toString(),
        "sort" to filters.sort
    )
    ticketRepository.getTickets(params)
}
I want to merge the results from these flows so that they appear as a single list instead of flowing separately. How can I achieve this? Any suggestions on how to properly combine these
PagingData
flows into one? Thanks!
c
How do you know which „page” you are requesting if you combine multiple requests?
n
Both request could be on same page, just the response needs to be in a common paging source, looks like if I can't do this with flows then, I would need to call multiple APIs in Paging Source itself and then return in the resulting PagingSource, but it doesn't look that clean
c
I’d move the whole logic for requesting the 2 pages to the repository and let the repo return the aggregated paging data.
174 Views