DBFlow icon indicating copy to clipboard operation
DBFlow copied to clipboard

TableChangedListener never notified

Open josh-bartz opened this issue 6 years ago • 4 comments

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.

josh-bartz avatar Oct 10 '18 15:10 josh-bartz

This looks like a bug . Which flowable are you using? Or a sample of what you are trying to do in the code

agrosner avatar Oct 15 '18 21:10 agrosner

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.

josh-bartz avatar Oct 16 '18 18:10 josh-bartz

How are you updating your items in the table? Just curious to understand.

agrosner avatar Oct 22 '18 13:10 agrosner

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.

josh-bartz avatar Oct 22 '18 19:10 josh-bartz