Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually refresh paging data in jetpack compose

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?

like image 736
Annon Avatar asked Oct 23 '25 19:10

Annon


1 Answers

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 new PagingData with a new instance of PagingSource to represent an updated snapshot of the backing dataset. If a RemoteMediator is set, calling refresh will also trigger a call to RemoteMediator.load with REFRESH to allow RemoteMediator to check for updates to the dataset backing PagingSource.

Note: This API is intended for UI-driven refresh signals, such as swipe-to-refresh

like image 199
Om Kumar Avatar answered Oct 26 '25 08:10

Om Kumar