0PricingLogin
Jetpack Compose Academy · Lesson

Reactive Queries Returning Flow

Observe the database in Compose.

Static Reads Go Stale

A one-time query gives you data once, but the table keeps changing. You want the UI to refresh whenever rows are added or removed.

Return a Flow Instead

Change a DAO query to return a Flow. Room now emits a fresh list every single time the underlying table changes. 🔄

@Query("SELECT * FROM Note")
fun observeAll(): Flow<List<Note>>

All lessons in this course

  1. Entities, DAOs & the Database
  2. Reactive Queries Returning Flow
  3. The Repository Pattern
  4. Offline-First Caching Strategy
← Back to Jetpack Compose Academy