ObservableMapExtensions

Simple utility function for the ObservableMaps.

Functions

Link copied to clipboard
fun <K, V> ObservableMutableMap<K, V>.updateOrNull(key: K, valueUpdate: V.() -> Unit): V?

Updates the value associated with the given key in the map by applying the provided transformation function. If the key does not exist or its current value is null, no operation is performed, and null is returned.

Link copied to clipboard
fun <K, V> ObservableMutableMap<K, V>.upsertValue(key: K, valueUpdate: (V?) -> V)

Inserts or updates a key-value pair in the ObservableMutableMap. If the key already exists, its value is updated using the provided transformation function. If the key does not exist, a new key-value pair is added with the value derived from the transformation function.