LiveMap

@ThreadSafe
class LiveMap<K, V> : MutableMap<K, V>

Like LiveVar, but for maps.

In other words, adding or removing to the map will cause the active section to rerender automatically.

For example:

val num2Names = liveMapOf(1 to "one", 2 to "two", 3 to "three")
section {
num2Names.forEach { (num, name) -> textLine("$num is spelled \"$name\"") }
}.run {
num2Names.putAll(mapOf(4 to "four", 5 to "five", 6 to "six"))
}

This class is thread safe and expected to be accessed across different threads.

Properties

Link copied to clipboard
Link copied to clipboard
open override val keys: MutableSet<K>
Link copied to clipboard
open override val size: Int
Link copied to clipboard
open override val values: MutableCollection<V>

Functions

Link copied to clipboard
open override fun clear()
Link copied to clipboard
open override fun containsKey(key: K): Boolean
Link copied to clipboard
open override fun containsValue(value: V): Boolean
Link copied to clipboard
open operator override fun get(key: K): V?
Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
open override fun put(key: K, value: V): V?
Link copied to clipboard
open override fun putAll(from: Map<out K, V>)
Link copied to clipboard
open override fun remove(key: K): V?
Link copied to clipboard
fun <R> withReadLock(block: LiveMap<K, V>.() -> R): R

Allow calls to lock the map for a longer time than just a single field at a time, useful if reading many fields at once.

Link copied to clipboard
fun <R> withWriteLock(block: LiveMap<K, V>.() -> R): R

Allow calls to write lock the map for a longer time than just a single field at a time, useful if updating many fields at once.