1

I am trying to use a paging library in my project but when I try to recieve LiveData<PageList<Entity>> data it's value is always null. My implementation looks like this:

DAO

@Query("SELECT * FROM entity")
fun getAll(): DataSource.Factory<Int, Entity>

ViewModel

    val pagedListConfig = PagedList.Config.Builder()
            .setEnablePlaceholders(false)
            .setPageSize(20).build()

    val data = LivePagedListBuilder(database.getAll(), pagedListConfig)
                .build()
                .value

The data variable is always null.

J.J.
  • 17
  • 5
Jan Maděra
  • 521
  • 3
  • 5
  • 17

1 Answers1

2

Very simple, you're still working LiveData, so it should be just:

val data = LivePagedListBuilder(database.getAll(), pagedListConfig).build()

Then data is LiveData which you should observe.

NoHarmDan
  • 492
  • 5
  • 16