//Extensions for Jetpack Lifecycle/it.czerwinski.android.lifecycle.livedata/combineLatest

combineLatest

[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.

Example:

val userLiveData: LiveData = ... val avatarUrlLiveData: LiveData = ... val userWithAvatar: LiveData<Pair<User?, String?>> = combineLatest(userLiveData, avatarUrlLiveData)

[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 <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, 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.

combineFunction will be executed on the main thread.

Example:

val userLiveData: LiveData = ... val avatarUrlLiveData: LiveData = ... val userWithAvatar: LiveData = combineLatest(userLiveData, avatarUrlLiveData) { user, avatarUrl -> UserWithAvatar(user, avatarUrl) }

[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.

combineFunction will be executed on the main thread.

[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.

combineFunction will be executed on the main thread.