SingleLiveData

class SingleLiveData<T>(liveData: LiveData<T>) : MediatorLiveData<T>

Constructors

Link copied to clipboard
constructor(liveData: LiveData<T>)

Properties

Link copied to clipboard

Emits the items that are different from all the values that have been emitted so far

Link copied to clipboard

Emits the items that are different from the last item

Link copied to clipboard

Emits at most 1 item and returns a SingleLiveData

Link copied to clipboard

Emits only the values that are not null

Link copied to clipboard

Converts a LiveData to a MutableLiveData with the initial value set by this LiveData's value

Link copied to clipboard

Converts a LiveData to a SingleLiveData

Functions

Link copied to clipboard
open fun <S : Any> addSource(@NonNull p0: LiveData<S>, @NonNull p1: Observer<in S>)
Link copied to clipboard
fun <T> LiveData<T>.buffer(count: Int): MutableLiveData<List<T?>>

Buffers the items emitted by the LiveData, and emits them when they reach the count as a List.

Link copied to clipboard
fun <T> LiveData<T>.concatWith(otherLiveData: LiveData<T>): LiveData<T>
Link copied to clipboard
fun <T> LiveData<T>.defaultIfNull(default: T): LiveData<T>

Emits the default value when a null value is emitted

Link copied to clipboard

emits the item that was emitted at index position Note: This only works for elements that were emitted after the elementAt is applied.

Link copied to clipboard
inline fun <T> LiveData<T>.filter(crossinline predicate: (T?) -> Boolean): LiveData<T>

Emits the items that pass through the predicate

Link copied to clipboard
open fun getValue(): T?
Link copied to clipboard
Link copied to clipboard
open fun hasObservers(): Boolean
Link copied to clipboard
Link copied to clipboard
fun <T> LiveData<T>.mergeWith(vararg liveDatas: LiveData<T>): LiveData<T>

Merges this LiveData with another one, and emits any item that was emitted by any of them

Link copied to clipboard

Emits only the values that are not null

Link copied to clipboard

Notifies the observer with the same live data as it holds

Link copied to clipboard
Link copied to clipboard
inline fun <T> LiveData<SingleEvent<T>>.observeEvent(owner: LifecycleOwner, crossinline onEventUnhandledContent: (T) -> Unit)
Link copied to clipboard
Link copied to clipboard
fun <T> LiveData<T>.observeOnce(observer: Observer<T>)
Link copied to clipboard
open override fun postValue(p0: T)
Link copied to clipboard
fun <T> MutableLiveData<T>.postValueIfNew(newValue: T)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun setValue(p0: T)
Link copied to clipboard
fun <T> MutableLiveData<T>.setValueIfNew(newValue: T)
Link copied to clipboard
fun <T> LiveData<T>.skip(count: Int): LiveData<T>

Skips the first n values

Link copied to clipboard
inline fun <T> LiveData<T>.skipUntil(crossinline predicate: (T?) -> Boolean): LiveData<T>

Skips all values until a certain predicate is met (the item that actives the predicate is also emitted)

Link copied to clipboard
fun <T> LiveData<T>.startWith(startingValue: T?): LiveData<T>

Emits the startingValue before any other value.

Link copied to clipboard
fun <T> LiveData<T>.take(count: Int): LiveData<T>

Emits the first n valueus

Link copied to clipboard
inline fun <T> LiveData<T>.takeUntil(crossinline predicate: (T?) -> Boolean): LiveData<T>

Takes until a certain predicate is met, and does not emit anything after that, whatever the value.

Link copied to clipboard
fun <T> LiveData<T>.then(otherLiveData: LiveData<T>): LiveData<T>

Converts the LiveData to SingleLiveData and concats it with the otherLiveData and emits their values one by one