MutableReactiveList

A mutable list that also exposes a StateFlow via asStateFlow, allowing for reactive observation of its contents.

It delegates MutableList functionality to an internal list and emits an immutable List snapshot to its collectors whenever the list is modified.

Parameters

E

The type of elements contained in the list.

Properties

Link copied to clipboard
abstract override val size: Int

Functions

Link copied to clipboard
abstract override fun add(element: E): Boolean
abstract fun add(index: Int, element: E)
Link copied to clipboard
abstract override fun addAll(elements: Collection<E>): Boolean
abstract fun addAll(index: Int, elements: Collection<E>): Boolean
Link copied to clipboard
abstract fun asStateFlow(): StateFlow<List<E>>

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

Link copied to clipboard
abstract fun batchUpdate(block: MutableList<E>.() -> 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 batchUpdateAsync(block: suspend MutableList<E>.() -> Unit)

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

Link copied to clipboard
abstract override fun clear()
Link copied to clipboard
abstract operator override fun contains(element: E): Boolean
Link copied to clipboard
abstract override fun containsAll(elements: Collection<E>): Boolean
Link copied to clipboard
abstract operator fun get(index: Int): E
Link copied to clipboard
fun <E> MutableReactiveList<E>.getAsFlow(index: Int): Flow<E?>

Creates a Flow that emits the element at the specified index whenever the list changes.

Link copied to clipboard
abstract fun indexOf(element: E): Int
Link copied to clipboard
abstract override fun isEmpty(): Boolean
Link copied to clipboard
abstract operator override fun iterator(): Iterator<E>
Link copied to clipboard
abstract fun lastIndexOf(element: E): Int
Link copied to clipboard
abstract override fun listIterator(): MutableListIterator<E>
abstract override fun listIterator(index: Int): MutableListIterator<E>
Link copied to clipboard
abstract override fun remove(element: E): Boolean
Link copied to clipboard
abstract override fun removeAll(elements: Collection<E>): Boolean
Link copied to clipboard
abstract fun removeAt(index: Int): E
Link copied to clipboard
abstract override fun retainAll(elements: Collection<E>): Boolean
Link copied to clipboard
abstract operator fun set(index: Int, element: E): E
Link copied to clipboard
abstract override fun subList(fromIndex: Int, toIndex: Int): MutableList<E>
Link copied to clipboard
fun <E> MutableReactiveList<E>.subListAsFlow(fromIndex: Int, toIndex: Int, strict: Boolean = true): Flow<List<E>>

Returns a Flow that emits a sublist view of this reactive list between the specified fromIndex (inclusive) and toIndex (exclusive).

Link copied to clipboard

Returns a new MutableReactiveList filled with all elements of this collection.

Link copied to clipboard

Returns a new MutableReactiveSet filled with all elements of this collection.