I have LazyColumn with nested LazyRow lists.
Each row use Flow<PaginData<UiObj>> for showing data.
LazyColumn() {
items(
items = showcaseRefList,
key = { it.urn },
contentType = { "showcaseRow" }
) {
val showcaseRowViewModel: ShowcaseRowViewModel =
koinViewModel(key = it.urn) {
parametersOf(
it.urn,
it.type.nameType
)
}
ShowcaseRow(
uiModelShowcasePageItem = it,
itemFlow = showcaseRowViewModel.pagerFlow,
onShowcaseItemClick = { }
)
}
}
PaginData i get using Pager with RemoteMediator and PagingSource from room.
@OptIn(ExperimentalPagingApi::class)
val pagerFlow = Pager(
config = PagingConfig(
pageSize = 20,
initialLoadSize = 1,
prefetchDistance = 5
),
remoteMediator = remoteMediator,
pagingSourceFactory = pagingSourceFactory
).flow
.cachedIn(viewModelScope)
pagingSourceFactory i got from room
@Query("select * from DbModelShowcaseBaseItem where parentUrn = :urn order by `order`")
abstract fun getShowcaseItemsByUrnPagingSource(urn: String): PagingSource<Int, DbModelShowcaseItem>
When i start scroll first row and remoteMediator get api request and save data in room, all pagingSource call invalidate callback and i have glitch with blinkin items. Glitch on lazyRow
Flow<PaginData> use .cahceIn with viewModelScope (each row have separate viewModel)
How islolate all this invalidation?
If i use .disinctUntilChange. its not working becase room always generate new PagingSource object in factory