2

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

2
  • Any updates about this? I have the same issue in all my LazyGrids. Commented Mar 28, 2024 at 8:09
  • Nope, still try find good solution XD Commented Apr 23, 2024 at 8:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.