0

While using the Paging 3 library, I'm trying to return a LiveData object containing the PagingData from the Repository to the ViewModel. But the Pager.liveData method is throwing an unresolved reference error. Is the .liveData method deprecated in Paging 3? But, I sometimes see some YouTube tutorials use this method on the Pager. How else can I return a LiveData object on the PagingData from the Pager?

Repository

@Singleton
class ShoppingListItemsRepositoryImpl @Inject constructor(
    private val shoppingListItemDao: ShoppingListItemDao,
    private val shoppingListItemMapper: ShoppingListItemMapper
) : ShoppingListItemsRepository {

    override fun getAllShoppingListItems(): LiveData<PagingData<ShoppingListItem>> {

        val pagingSourceFactory = { shoppingListItemDao.getAllShoppingListItems() }

        return Pager(
            config = PagingConfig(
                pageSize = 10,
                enablePlaceholders = false
            ),
            pagingSourceFactory = pagingSourceFactory
        ).liveData.map { ... }
    }
}
Raj Narayanan
  • 2,443
  • 4
  • 24
  • 43

0 Answers0