https://kotlinlang.org logo
#android
Title
# android
p

paulex

12/24/2020, 6:33 PM
How would you implement a search using Paging3 I’ve tried resubscribing to the paging source , but the result isn’t very good
google 3
d

Dustin Lam

12/24/2020, 6:56 PM
Generally you should do it in a flow based way
Copy code
queryFlow.flatMap { query ->
  Pager(..) {
    PagingSource(query)
  }
}.cachedIn(viewModelScope)
If you want to pass it to combine instead for say filter:
Copy code
Pager(..) { .. }
  .cachedIn(viewModelScope)
  .combine(queryFlow) { query, pagingData ->
pagingData.filter { ... }
}