multiplatform-paging icon indicating copy to clipboard operation
multiplatform-paging copied to clipboard

LazyPagingItems.refresh has no effect

Open mikedawson opened this issue 1 year ago • 0 comments

I have a PagingSource Factory in a ViewModel (Compose/Desktop) where parameters can change based on events (e.g. user changes sort order, search query, etc). I want to call LazyPagingItems.refresh() to trigger generating a new PagingSource and a call to RemoteMediator.load .

I am using this in compose:

val pager = remember(uiState.personList) {
    Pager(
        config = PagingConfig(pageSize = 20, enablePlaceholders = true, maxSize = 200),
        pagingSourceFactory = {
            Napier.d("PersonListScreen: Invoke pagingSourceFactory")
            uiState.personList()
        },
        remoteMediator = DoorRepositoryRemoteMediator(uiState.personList),
    )
}

val lazyPagingItems = pager.flow.collectAsLazyPagingItems()

LaunchedEffect(listRefreshCommand) {
    listRefreshCommand.collect {
        Napier.d("PersonListScreen: refresh lazypagingitems")
        lazyPagingItems.refresh()
    }
}

I got a log line that shows Refresh signal received (probably from PagingDataPresenter.kt). However there is no invocation of the PagingSourceFactory and no call to remotemediator.load.

This is using version 3.3.0-alpha02-0.5.1 . The project can be found here - example file PersonListScreen

mikedawson avatar Mar 26 '24 18:03 mikedawson