Jagtej Sodhi
07/13/2023, 8:52 PMJohn O'Reilly
07/13/2023, 8:58 PMJagtej Sodhi
07/13/2023, 9:33 PMloadNext()
function is exposed, which is great.
But, I was trying to determine how to mimic that using Cashapp's library. Perhaps I need to call load in the paging source directly?veyndan
07/13/2023, 9:34 PMJagtej Sodhi
07/13/2023, 9:36 PMveyndan
07/13/2023, 9:49 PMPagingDataDiffer
in iOS and hook up the necessary things (sorry it's a bit handwavy as idk Swift UI). Then, whenever you call PagingDataDiffer#get
(which retrieves an item at an index), that function will internally check if it should load the next page of data or not.
So essentially you shouldn't need to programatically trigger another page load. By incrementally loading data as you scroll, additional pages will be loaded as needed.
Quick example — assume you have page sizes of 30, your view port can show 10 items at a time, and you have configured to load the next page when you're 5 items before the end of the page. When you call get
on the first 10 items on screen, no additional page loads are required. When you scroll a bit and show the item range 16 to 26 on screen, you're now 5 away, and paging will internally trigger an additional page load.veyndan
07/13/2023, 9:53 PMPagingDataDiffer
approach is what paging-compose
does under the hood. Here's the implementation, which may or may not be useful.