Osman Saral
10/10/2023, 8:46 PM1.6.0-alpha01
to 1.6.0-alpha02
my Pager
is broken. The items are not loaded and the PagingData
is not updated. I couldn't see any androidx.paging
related change in the commits but maybe something else on the commit list causes this.Ian Lake
10/10/2023, 8:59 PMandroidx.paging
version - those are totally decoupled from one anotherOsman Saral
10/11/2023, 7:48 AMPagingData
is not updated.Osman Saral
10/11/2023, 11:00 AMfun page(type: String) = Pager(
config = PagingConfig(pageSize = 10),
pagingSourceFactory = {
TenantPagingSource(getTenantListUseCase, type)
}
).flow.cachedIn(viewModelScope)
and collected like this:
viewModel.page("shop").collectAsLazyPagingItems()
This works with 1.6.0-alpha01
but doesn't work with 1.6.0-alpha02
When I fix it like this
val page = Pager(
config = PagingConfig(pageSize = 10),
pagingSourceFactory = {
TenantPagingSource(getTenantListUseCase, "shop")
}
).flow.cachedIn(viewModelScope)
or collect like this:
val shops = remember {
viewModel.page("shop")
}.collectAsLazyPagingItems()
it works on the alpha02 too:
But I really wonder how it's related to the compose version.Ian Lake
10/11/2023, 1:40 PMPager
every time your page
function is called was only ever working by chance and was never how you should have had it set upIan Lake
10/11/2023, 1:48 PMflatMapLatest
on that flow to create the Pager and return the Flow from it, then cachedIn the result.
Then whenever your type changes, a new Pager and PagingSource gets createdIan Lake
10/11/2023, 1:50 PMSavedStateHandle
, so you wouldn't need to pass the type manually to your ViewModel everOsman Saral
10/16/2023, 6:21 PM