MutableReactiveCollection

interface MutableReactiveCollection<E, out IC, out MC : IC>

A foundational interface for mutable collections that expose their state as a StateFlow.

This allows observers to reactively receive updates whenever the collection is modified. The emitted value is an immutable snapshot of the collection at the time of modification.

Parameters

E

The type of elements in the collection.

IC

The type of immutable collection snapshot emitted by the StateFlow (e.g., List, Set, Map).

MC

The underlying mutable collection type that this interface wraps (e.g., MutableList, MutableSet, MutableMap).

Inheritors

Functions

Link copied to clipboard
abstract fun asStateFlow(): StateFlow<IC>

Returns the collection's content as a StateFlow of an immutable collection IC type.

Link copied to clipboard
abstract fun batchNotify(block: MC.() -> Unit)

Executes a block of modifications on the underlying mutable collection and notifies observers only once after the block has completed.

Link copied to clipboard
abstract suspend fun batchNotifyAsync(block: suspend MC.() -> Unit)

Executes a suspending block of modifications on the underlying mutable collection and notifies observers only once after the block has completed.