Skip to content

Coroutines

Flow

To consume a query as a Flow, depend on the Coroutines extensions artifact and use the extension method it provides:

dependencies {
  implementation("app.cash.sqldelight:coroutines-extensions:2.0.0-alpha05")
}
dependencies {
  implementation "app.cash.sqldelight:coroutines-extensions:2.0.0-alpha05"
}
val players: Flow<List<HockeyPlayer>> = 
  playerQueries.selectAll()
    .asFlow()
    .mapToList()

This flow emits the query result, and emits a new result every time the database changes for that query.