I'm trying to adopt PagedList
to my app. One of the functionality I want is the ability to handle button click event within list item.
I was thinking to utilize ViewModel
to listen for the click event and taken from the example https://medium.com/@star_zero/singleliveevent-livedata-with-multi-observers-384e17c60a16, I was successfully getting the click event.
so I have,
LivePagedListBuilder(DeviceDataSourceFactory(), defaultConfig)
.build()
.observe(this, Observer { list ->
// here is where I have Observer for the click event
// for example, list?.forEach { it.event.observe(...) }
// but this block isn't called everytime
adapter.submitList(list)
})
As the comment above, I don't always get notified when new item is added to the list. I guess I only got it once from loadInitial
and once from loadAfter
. After ref is linked, PagedList
handles updating the list itself without notifying the Observer. Therefor, I can't correctly setup click event Observer. Any help would be appreciated. been blocked for more than a week. Thanks!