FlowStore

interface FlowStore<K : Any, V : Any>(source)

Read view of a store-backed map. Exposes the delta stream and per-key access only; there is no full-map snapshot, so values are read through to the store on a miss.

The value V must be an aggregate root: every write replaces a key's value as a whole (no field-level or partial updates), so each VersionedMapEvent.Upsert carries the full value and a miss reads the whole value back. With single-writer-per-key ownership this makes a key's version sequence totally ordered.

Inheritors

Properties

Link copied to clipboard
abstract val async: AsyncFlowStore<K, V>

A suspending view of this store whose AsyncFlowStore.get dispatches the read-through itself.

Functions

Link copied to clipboard

The live, delta-only stream of versioned mutations.

abstract fun asFlow(query: () -> Map<K, Versioned<V>>, predicate: (K, V) -> Boolean = { _, _ -> true }): Flow<VersionedMapEvent<K, V>>

A get-and-subscribe view: emits the entries query loads now (as VersionedMapEvent.Upsert), then follows the live stream, version-gated per key so the snapshot and the tail never conflict. query is the bulk current state (key to value+version); it runs blocking on the store's dispatcher and is not written to the cache. predicate scopes the live tail to the same logical set: a live upsert that matches enters or updates the view, one that stops matching leaves it as a VersionedMapEvent.Removed, and removals forward only for keys in the view. query and predicate must agree (query = current rows matching predicate).

Link copied to clipboard
abstract fun get(key: K): V?

The latest value for key: cache-first, reading through to the store on a miss. The read-through is blocking — call it within an IO context, as with the store's writes. Not ordered against asFlow: a value just published as a delta may not be visible here yet.

Link copied to clipboard
abstract fun valueFlow(key: K): Flow<V?>

The latest value for key, starting from a read-through load then following the stream.