multiplatform-paging icon indicating copy to clipboard operation
multiplatform-paging copied to clipboard

Empty PagingData list

Open ixiDev opened this issue 2 years ago • 2 comments
trafficstars

Hi, Thanks for this lib.

Is it possible to make the function List<T>.toPagingData() in PagingData.kt public so we can create empty paging list as in Paging3 (PagingData.empty())

Here is where we can use it for example;

  val list by pager.pagingData.collectAsState(
       emptyPaging()
    )

ixiDev avatar May 02 '23 10:05 ixiDev

Hi. I apologize for not maintaining this library very well. May I ask what's the use case for this? I normally would just use a nullable because an empty list means it has tried to load the list but it's empty. My preference is to use a null to signify and to know that nothing has been loaded yet.

kuuuurt avatar May 02 '23 14:05 kuuuurt

In Jetpack compose the ** collectAsState** need an initial value so normally we pass empty list because the LazyColumn cannot accept nullable value. And also we need it when we create FlowState in ViewModel.

Check the source of PagingData PagingData.kt and doc PagingData.empty()

ixiDev avatar May 03 '23 12:05 ixiDev