mapToValueOrUnset

fun <K, V> LiveData<Map<K, V>>.mapToValueOrUnset(key: K): LiveData<V>

Maps the value of the provided key, if that key exists in this map. Otherwise, no value is set. This is useful in cases where the map may not contain the requested entry but the resulting LiveData is not nullable as the client does not care about a null value. This removes the need for the client to have null checks in its code wherever the resulting LiveData is used.

Note that as this function is intended for use by clients which do not care about a null value, no value is emitted by the resulting LiveData if there is a value which then disappears.