watch

abstract fun <RowType : Any> watch(sql: String, parameters: List<Any?>? = listOf(), throttleMs: Long = DEFAULT_THROTTLE.inWholeMilliseconds, mapper: (SqlCursor) -> RowType): Flow<List<RowType>>

Executes a read-only (SELECT) query every time the source tables are modified and returns the results as a Flow of lists.

Return

A Flow emitting lists of results.

Parameters

sql

The SQL query to execute.

parameters

The parameters for the query, or an empty list if none.

throttleMs

The minimum interval, in milliseconds, between queries. Defaults to DEFAULT_THROTTLE.

mapper

A function to map the result set to the desired type.

Throws

If a database error occurs.

If the operation is cancelled.