Fixed
Status Update
Comments
cl...@google.com <cl...@google.com> #2
Fixed internally in 3.3.0-alpha03
to...@marginalen.se <to...@marginalen.se> #3
This issue is still present in both 3.3.0-alpha03 and 3.3.0-alpha04. I tried this:
val test = flowOf(PagingData.empty<String>()).collectAsLazyPagingItems()
Timber.d("Findme: is test refreshing ${test.isRefreshing}")
Output:
Findme: is test refreshing true
:/
val test = flowOf(PagingData.empty<String>()).collectAsLazyPagingItems()
Timber.d("Findme: is test refreshing ${test.isRefreshing}")
Output:
Findme: is test refreshing true
:/
cl...@google.com <cl...@google.com> #4
In theory LazyPagingItems
would immediately return NotLoading
only if it is loading from cached data. Otherwise, if it is loading from fresh data (even if the list of data is empty), it defaults to Loading
.
In a real world, you would cache data with pager.flow.cachedIn(scope)
. In your example, you would have to "fake" cached data if you want to simulate loading from cached data.
You can do that by creating a SharedFlow
(because internally, Paging cache is implemented with SharedFlow). So for example:
val test = MutableStateFlow(PagingData.empty<String>()).collectAsLazyPagingItems()
You will notice that MutableStateFlow
as well.
Description
Component used: androidx.paging:paging-compose
Version used: 3.2.1
Devices/Android versions reproduced on: Pixel 6 Pro API 32 emulator
That last line shouldn't pass. Both cachedPageEvent that's in the
empty
the API call andfrom(emptyList())
should be marked as not loading. Ian mentioned the difference was in thefrom
method, but not theempty
one.For what it's worth, I would consider this a breaking API change. In places where people were relying on
empty
to be an initial loading state to show a progress indicator, it won't if this bug is fixed.As an alternative, maybe expose a
PagingData.loading()
which does whatempty
does now.