cashapp / multiplatform-paging

A library that packages AndroidX Paging for Kotlin/Multiplatform.
Apache License 2.0
568 stars 28 forks source link

LazyPagingItems.refresh has no effect #241

Open mikedawson opened 7 months ago

mikedawson commented 7 months ago

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