kuuuurt / multiplatform-paging

Kotlin Multiplatform library for Pagination
Apache License 2.0
251 stars 22 forks source link

Empty PagingData list #36

Open ixiDev opened 1 year ago

ixiDev commented 1 year ago

Hi, Thanks for this lib.

Is it possible to make the function List.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()
    )
kuuuurt commented 1 year ago

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.

ixiDev commented 1 year ago

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()](https://developer.android.com/reference/androidx/paging/PagingData#empty())