upsertValue

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.

Parameters

key

The key to be added or updated in the map.

valueUpdate

A function that computes the new value based on the current value (or null if the key does not exist).