ImmutableLiveData
A LiveData class which has the value set during construction.
Clients may prefer to use this class rather than androidx.lifecycle.MutableLiveData:
If this class is more convenient to use. With this class, in a single call, a LiveData instance with a value already set can be created.
If they would like to guarantee with typing that the LiveData will not change.
Parameters
The value to set.
Inherited properties
Same as LiveData.getValue, except this variant throws a IllegalStateException when the LiveData instance does not have an active observer.
Same as LiveData.getValue with the exception that the returned value is up to date even when the LiveData instance does not have an observer.
Inherited functions
Returns the value corresponding to the given key in the LiveData's value, or defaultValue if such a key is not present in the map or the LiveData has no value.
Executes and switchMaps to block if this
has a true
value. If this
is false
or null
, it returns LiveData with value default. This can be used instead of ifTrue when the default value should be something other than null
. Note that this requires a non-null value for T in order for Kotlin's compiler to properly spot missing null
-checks.
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.
Creates a MutableLiveData from LiveData by specifying the setter to use to the change the value.