In my ViewModel, I load data using
private val pagingConfig = PagedList.Config.Builder()
.setEnablePlaceholders(false)
.setInitialLoadSizeHint(INITIAL_LOAD_SIZE_HINT)
.setPageSize(PAGE_SIZE)
.build()
val notificationList = LivePagedListBuilder<Long, Notification>(dataSourceFactory, pagingConfig).build()
Which works fine. However, when my data changes, LiveData<PagedList<Notification>> does not get notified. Is there anything I can do to trigger LiveData refresh (the ViewModel knows when the change occurs).
You can trigger data update using invalidate() method from the DataSource.
When using the Paging Library, it's up to the data layer to notify the other layers of your app when a table or row has become stale. To do so, call
invalidate()from theDataSourceclass that you've chosen for your app.
More information: Notify when data is invalid
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With