Observability
August 23, 2026 ยท View on GitHub
TableObserver records table writes (via triggers) when a transaction finishes. toFlow re-runs a query when those tables change.
val users: Flow<List<User>> =
userAdapter.select().toFlow(db) { list() }
(userAdapter.select() where (User.name like "A%"))
.toFlow(db, runQueryOnCollect = false) { singleOrNull() }
runQueryOnCollect = true (default) emits immediately on collect. Set false if the first single() would throw on an empty table.
Writes must go through a DBFlow transaction so the observer runs. For a one-shot coroutine transaction as a Flow:
db.beginTransactionAsync { userAdapter.select().list() }.toFlow()