I’m working on a project using RoomDB (version 2.6...
# room
m
I’m working on a project using RoomDB (version 2.6.1) where I have a complex query involving GROUP BY and AS statements to create an entity on the fly. It works as expected on most devices, but QA testing on older devices revealed an unexpected behavior: When collecting the Flow in the collect block, the first emission is almost immediately an empty list, and then the actual list of entities is emitted a few seconds later. This happens even though the database has data ready. The process relies on an action being performed before the items are collected, but the empty initial emission causes incorrect behavior. Is this expected for observable queries in RoomDB? How can I prevent the empty initial emission? Thank yoy
b
WIthout seeing the query and structure it's hard to say. On your query try adding
@Transaction
and see if that helps.
m
Thank you for your help. I realise that it’s not as a result of RoomDB, but my flawed implementation. I tried to map the values in the flow before collecting it in another operation. Flow.map is not a terminal operation nor does it suspend, that’s why the operation ran immediately and it seemed like it was returning an empty list. I just moved the Flow.collect operation into my apiCall {} coroutine scope and it worked as expected. So false alarm on my part 🙏🏾