DbInvalidationController

class DbInvalidationController(enabled: Boolean, notifyKey: (String) -> Unit)

Controls SQLDelight query invalidations (notifyListeners).

Purpose: SQLDelight triggers notifyListeners() after most write operations, which can cause excessive recompositions, Flow emissions and cache invalidations when processing large batches of events.

This controller allows temporarily muting invalidations and aggregating them:

  • While muted, all notifyListeners calls are intercepted.

  • Query keys are accumulated and deduplicated.

  • When the outermost mute scope finishes, all accumulated keys are flushed in a single notifyListeners call.

This significantly reduces UI / Flow churn during batch processing (e.g. Incremental Sync).

Constructors

Link copied to clipboard
constructor(enabled: Boolean, notifyKey: (String) -> Unit)

Functions

Link copied to clipboard
fun isEnabled(): Boolean
Link copied to clipboard
fun isMuted(): Boolean
Link copied to clipboard
internal fun onNotify(queryKeys: Array<out String>)
Link copied to clipboard
suspend fun <T> runMuted(block: suspend () -> T): T

Runs block while invalidations are muted. Safe for nesting (re-entrant via muteDepth).