DBFlow
DBFlow copied to clipboard
TableChangedListener never notified
DBFlow Version:
4.24.0
Bug or Feature Request:
Bug
Description:
I was trying to retrieve a list of objects using an RxJava Flowable
, similarly to the method described here:
https://medium.com/fuzz/how-to-make-dbflow-as-testable-as-room-with-kotlin-b1694f3f80ad
But the Flowable
only returns the values once. It never receives updates when I insert or delete items. I discovered that if I set up a DirectModelNotifier
, registerForModelChanges
will work (onModelChanged
observes Actions
), but registerForTableChanges
won't observe anything.
I'm using Kotlin and my model is a data class.
This looks like a bug . Which flowable are you using? Or a sample of what you are trying to do in the code
I've tried this:
fun getAllItemsRX(userUUID: String): Flowable<List<Item>> =
(select
from Item::class
where Iteml_Table.userUUID.eq(userUUID))
.rx()
.observeOnTableChanges()
.observeOn(Schedulers.io())
.map { it.queryList() }
And only get results when initially subscribing, not after updating the table.
And this:
DirectModelNotifier.get().registerForTableChanges(Item::class.java) { _, action ->
}
And never get any updates.
How are you updating your items in the table? Just curious to understand.
I've tried a few things. Kotlin extensions item.save()
and item.insert()
. FlowManager.getModelAdapter(Item::class.java).save(item)
. I've tried each of those inside and outside of transactions.