6

Basically I have a paging data flow collected in a composable function:

val list = state.listFlow.collectAsLazyPagingItems()

Each item on the list has a call-to-action button that will enable/disable the view and update the UI of the corresponding item.

My question is, how can we update the visual state of the item without the need for calling refresh on the PagingData and therefore re-querying the API/database for updated data?

Also if user has scrolled through 5 pages or more I don't want to reload the whole content, changes can be local.

Any clues on how to achieve this?

Yogi Bear
  • 603
  • 8
  • 22

1 Answers1

0

This is almost impossible for Paging3, which requires immutable lists. See https://issuetracker.google.com/issues/160232968.

This problem bothered me for months and finally I decided to abandon Paging3 library and write my own paged list to avoid all these weird features. Most of the complexity of Paging3 is because it wants to encapsulate the paged list in one library, which needs the view layer and the model layer to work together.

This is the paged list I implemented: https://gist.github.com/FishHawk/6e4706646401bea20242bdfad5d86a9e

If your project does not have a deep dependency on the paging3 library, I highly recommend you try doing this.

FishHawk
  • 414
  • 4
  • 11