Reputation: 843
I'm using paging-compose library to load paginated data from server using remote mediator (backed by local room database). Is there any way to manually refresh mediator data in case of swipe to refresh?
Upvotes: 4
Views: 8189
Reputation: 1664
Calling refresh()
method on LazyPagingItems
should work for swipe to refresh (UI driven event) as mention in documentation LazyPagingItems.refresh()
Refresh the data presented by this
LazyPagingItems
.
refresh
triggers the creation of a newPagingData
with a new instance ofPagingSource
to represent an updated snapshot of the backing dataset. If aRemoteMediator
is set, calling refresh will also trigger a call toRemoteMediator.load
with REFRESH to allowRemoteMediator
to check for updates to the dataset backingPagingSource
.
Note: This API is intended for UI-driven refresh signals, such as swipe-to-refresh
Upvotes: 9