Package com.tomtom.tools.android.api.livedata
Types
An implementation of MutableLiveData that only emits updates when the value actually changed, i.e. when newValue != oldValue. This differs from regular MutableLiveData because if you set its value to an equal same value, it still emits an update, causing observers to get a callback.
An empty LiveData implementation for situations where we need a LiveData instance which will always have a null value.
A LiveData class which has the value set during construction.
A LiveData which updates its value every delayMs. Override computeValue to provide the new value for each period. Its value will only be updated while there are active observers.
A LiveData that applies a transformation to the value before setting it.
An empty LiveData implementation for situations where we need a LiveData instance which will never have a value.
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.
Functions
Convenience method for calling allTrue in a functional flow.
Convenience method for calling anyTrue in a functional flow.
Convenience method to create non-mutable LiveData fields without duplicating the type.
Transforms a list of LiveDatas containing any type of value using the given combineFunction. Whenever any of the sources are updated, the returned LiveData value is also updated.
Transforms two LiveDatas containing any type of value using the given combineFunction. Whenever any of the sources are updated, the returned LiveData value is also updated.
Transforms three LiveDatas containing any type of value using the given combineFunction. Whenever any of the sources are updated, the returned LiveData value is also updated.
Transforms four LiveDatas containing any type of value using the given combineFunction. Whenever any of the sources are updated, the returned LiveData value is also updated.
Transforms five LiveDatas containing any type of value using the given combineFunction. Whenever any of the sources are updated, the returned LiveData value is also updated.
Transforms multiple LiveDatas containing lists of type S, into one LiveData with a single list of type T. combineMapFunction is used to map each of the sources' items into a list.
Transforms a LiveData containing a list of type T, which contains all the child elements from each element in thisLiveData list by flattening it.
Transforms a LiveData containing a list of type T, which contains all the child elements from each element in thisLiveData list together with its source, by flattening it.
Performs operation on each entry in a LiveData's collection. Does nothing if the LiveData has no value.
Returns the value for the given key in the LiveData's value. If the key is not found, calls the defaultValue function, puts its result into the map under the given key and returns it. Creates a map if the LiveData has no value yet.
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.
Transforms LiveData containing a list that holds other LiveData instances into LiveData that contains the values from those LiveData instances. The returned LiveData will be updated when the source LiveData changes as well as when the internal LiveData instances change.
Removes a single instance of the specified element from a MutableLiveData, if it is present. The observers are notified of the new value if any of the specified elements was removed.
Removes all elements from this MutableLiveData that are also contained in the given elements collection. The observers are notified of the new value if the list was changed.
Removes the entry mapped by key from the LiveData's value, notifying observers of the new value.
Observes this LiveData for one change only and returns the one-time observer. The returned observer can be used to stop observing the LiveData when a callback is no longer desired. It is safe to remove the observer while it is executing or has been executed already.
Adds the specified element to the end of this MutableLiveData. The observers are notified of the new value.
Adds all of the elements of the specified collection to the end of this MutableLiveData. The observers are notified of the new value if the list was changed.
Removes all elements from this MutableLiveData that match the given predicate. The observers are notified of the new value if the list was changed.
Removes all elements from this MutableLiveData that are also contained in the given elements collection. The observers are notified of the new value if the list was changed.