【问题标题】:Manually refresh paging data in jetpack compose在jetpack compose中手动刷新分页数据
【发布时间】:2021-11-16 05:08:27
【问题描述】:

我正在使用 paging-compose 库通过远程调解器(由本地房间数据库支持)从服务器加载分页数据。有没有办法在刷卡刷新的情况下手动刷新中介数据?

【问题讨论】:

    标签: android android-jetpack-compose android-paging android-paging-3


    【解决方案1】:

    LazyPagingItems 上调用refresh() 方法应该适用于在documentation LazyPagingItems.refresh() 中提到的滑动刷新(UI 驱动事件)

    刷新此LazyPagingItems提供的数据。

    refresh 触发使用 PagingSource 的新实例创建新的 PagingData,以表示支持数据集的更新快照。如果设置了RemoteMediator,调用refresh 还将触发使用REFRESH 调用RemoteMediator.load,以允许RemoteMediator 检查支持PagingSource 的数据集的更新。

    注意:此 API 适用于 UI 驱动的刷新信号,例如 swipe-to-refresh

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-22
      • 1970-01-01
      • 2022-08-23
      • 1970-01-01
      • 2021-12-31
      • 2022-11-01
      • 2022-11-24
      • 2020-04-07
      相关资源
      最近更新 更多