//Extensions for Jetpack Lifecycle/it.czerwinski.android.lifecycle.livedata
Package it.czerwinski.android.lifecycle.livedata
[androidJvm]
Extensions for Jetpack Lifecycle
Types
Name | Summary |
---|---|
ConstantLiveData | [androidJvm] Content class ConstantLiveData<T>(value: T) : LiveData<T> More info LiveData that always emits a single constant value. |
GroupedLiveData | [androidJvm] Content class GroupedLiveData<K, V>(keySelector: (V) -> K) : MediatorLiveData<V> More info MediatorLiveData subclass which provides a separate LiveData per each result returned by keySelector function executed on subsequent values emitted by the source LiveData. |
Functions
Name | Summary |
---|---|
addDirectSource | [androidJvm] Content @MainThread() inline fun <T> MediatorLiveData<in T>.addDirectSource(source: LiveData<out T>) More info Starts to listen the given source LiveData. |
combineLatest | [androidJvm] Content fun <T> combineLatest(vararg sources: LiveData<T>): LiveData<List<T?» More info Returns a LiveData emitting lists of latest values emitted by the given source LiveData. [androidJvm] Content fun <A, B> combineLatest(first: LiveData<A>, second: LiveData<B>): LiveData<Pair<A?, B?» More info Returns a LiveData emitting pairs of latest values emitted by the first and the second LiveData. [androidJvm] Content fun <T, R> combineLatest(vararg sources: LiveData<T>, combineFunction: (List<T?>) -> R): LiveData<R> More info Returns a LiveData emitting results of applying the given combineFunction to the latest values emitted by the given source LiveData. [androidJvm] Content fun <A, B, C> combineLatest(first: LiveData<A>, second: LiveData<B>, third: LiveData<C>): LiveData<Triple<A?, B?, C?» More info Returns a LiveData emitting triples of latest values emitted by the first, the second and the third LiveData. [androidJvm] Content fun <A, B, R> combineLatest(first: LiveData<A>, second: LiveData<B>, combineFunction: (A?, B?) -> R): LiveData<R> More info Returns a LiveData emitting results of applying the given combineFunction to the latest values emitted by the first and the second LiveData. [androidJvm] Content fun <A, B, C, R> combineLatest(first: LiveData<A>, second: LiveData<B>, third: LiveData<C>, combineFunction: (A?, B?, C?) -> R): LiveData<R> More info Returns a LiveData emitting results of applying the given combineFunction to the latest values emitted by the first, the second and the third LiveData. |
defaultIfEmpty | [androidJvm] Content fun <T> LiveData<T>.defaultIfEmpty(defaultValue: T): LiveData<T> More info Returns a LiveData that emits the values emitted by this LiveData or a specified default value if this LiveData has not yet emitted any values at the time of observing. [androidJvm] Content fun <T> LiveData<T>.defaultIfEmpty(defaultValueProducer: () -> T): LiveData<T> More info Returns a LiveData that emits the values emitted by this LiveData or a value returned by defaultValueProducer if this LiveData has not yet emitted any values at the time of observing. |
delayStart | [androidJvm] Content fun <T> LiveData<T>.delayStart(timeInMillis: Long, context: CoroutineContext = EmptyCoroutineContext): LiveData<T> More info Returns a LiveData emitting values from this LiveData, after dropping values followed by newer values before timeInMillis expires since the result LiveData has been created. |
filter | [androidJvm] Content fun <T> LiveData<T>.filter(predicate: (T) -> Boolean): LiveData<T> More info Returns a LiveData emitting only values from this LiveData matching the given predicate. |
filterIsInstance | [androidJvm] Content inline fun <R> LiveData<*>.filterIsInstance(): LiveData<R> More info Returns a LiveData emitting only values of type R from this LiveData. |
filterNotNull | [androidJvm] Content fun <T> LiveData<T?>.filterNotNull(): LiveData<T> More info Returns a LiveData emitting only non-null values from this LiveData. |
groupBy | [androidJvm] Content fun <K, V> LiveData<V>.groupBy(keySelector: (V) -> K): GroupedLiveData<K, V> More info Returns a GroupedLiveData providing a set of LiveData, each emitting a different subset of values from this LiveData, based on the result of the given keySelector function. |
intervalLiveData | [androidJvm] Content fun intervalLiveData(timeInMillis: Long, context: CoroutineContext = EmptyCoroutineContext): LiveData<Int> More info Returns a LiveData emitting a sequence of integer values, spaced by a given timeInMillis. [androidJvm] Content fun intervalLiveData(context: CoroutineContext = EmptyCoroutineContext, timeInMillis: (Int) -> Long): LiveData<Int> More info Returns a LiveData emitting a sequence of integer values, spaced by a result of a given timeInMillis function invoked on the next value. |
mapNotNull | [androidJvm] Content fun <T, R> LiveData<T>.mapNotNull(transform: (T) -> R?): LiveData<R> More info Returns a LiveData emitting only the non-null results of applying the given transform function to each value emitted by this LiveData. |
merge | [androidJvm] Content fun <T> merge(vararg sources: LiveData<T>): LiveData<T> More info Returns a LiveData emitting each value emitted by any of the given LiveData. [androidJvm] Content infix fun <T> LiveData<T>.merge(other: LiveData<T>): LiveData<T> More info Returns a LiveData emitting each value emitted by either this or other LiveData. |
reduce | [androidJvm] Content fun <T> LiveData<T?>.reduce(operation: (T?, T?) -> T?): LiveData<T?> More info Returns a LiveData emitting accumulated value starting with the first value emitted by this LiveData and applying operation from left to right to current accumulator value and each value emitted by this. |
reduceNotNull | [androidJvm] Content fun <T> LiveData<T>.reduceNotNull(operation: (T, T) -> T): LiveData<T> More info Returns a LiveData emitting non-null accumulated value starting with the first non-null value emitted by this LiveData and applying operation from left to right to current accumulator value and each subsequent non-null value emitted by this LiveData. |
switch | [androidJvm] Content fun <T> LiveData<LiveData<T».switch(): LiveData<T> More info Converts LiveData that emits other LiveData into a single LiveData that emits the items emitted by the most recently emitted LiveData. |
throttleWithTimeout | [androidJvm] Content fun <T> LiveData<T>.throttleWithTimeout(timeInMillis: Long, context: CoroutineContext = EmptyCoroutineContext): LiveData<T> More info Returns a LiveData emitting values from this LiveData, after dropping values followed by newer values before timeInMillis expires. |