With Jetpack Compose Paging3, calling refresh() on paging items in Launch Effect block doesn't update the UI

Viewed 93

I've applied Paging3 compose with my Android Jetpack Compose project. In one of my screens, the following code is implemented to refresh the list on navigating back from another screen.

LaunchEffect(key1 = Unit) {
      items.refresh()
}

The initial recomposition on navigation back indeed triggers the lambda block in Launch Effect but doesn't reschedule the recomposition again to update the LazyColumn.

LazyColumn(
     modifier = Modifier.fillMaxSize()
) {
     item { Spacer(modifier = Modifier.height(14.dp)) }
     items(items) { item ->
          Item(blog = item!!)
     }
}

Please suggest me a solution to fix this. Right now, I've removed cacheIn() in view model just to force pager to refetch new objects but that'll bring back to page 1, apparently not how it's supposed to be. Also, if we wrap the lazy column with Swipe Refresh and manually refresh, bothe the data and UI got updated. Any solution for this?

0 Answers
Related