Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TripleCombinatorLiveData.java « combinator « reactivelivedata « android « niedermann « it « java « main « src « reactive-livedata - github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: de0353c428e35634c5c50b622131d8b1504df98d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package it.niedermann.android.reactivelivedata.combinator;

import androidx.annotation.NonNull;
import androidx.arch.core.util.Function;
import androidx.core.util.Supplier;
import androidx.lifecycle.LiveData;

import it.niedermann.android.reactivelivedata.ReactiveLiveData;
import kotlin.Triple;

public class TripleCombinatorLiveData<T, Y, Z> extends ReactiveLiveData<Triple<T, Y, Z>> {

    public TripleCombinatorLiveData(@NonNull LiveData<T> source, @NonNull Supplier<LiveData<Y>> secondSourceSupplier, @NonNull Supplier<LiveData<Z>> thirdSourceSupplier) {
        this(source, val -> secondSourceSupplier.get(), val -> thirdSourceSupplier.get());
    }

    public TripleCombinatorLiveData(@NonNull LiveData<T> source, @NonNull Function<T, LiveData<Y>> secondSourceFunction, @NonNull Supplier<LiveData<Z>> thirdSourceSupplier) {
        this(source, secondSourceFunction, val -> thirdSourceSupplier.get());
    }

    public TripleCombinatorLiveData(@NonNull LiveData<T> source, @NonNull Supplier<LiveData<Y>> secondSourceSupplier, @NonNull Function<T, LiveData<Z>> thirdSourceFunction) {
        this(source, val -> secondSourceSupplier.get(), thirdSourceFunction);
    }

    public TripleCombinatorLiveData(@NonNull LiveData<T> source, @NonNull Function<T, LiveData<Y>> secondSourceFunction, @NonNull Function<T, LiveData<Z>> thirdSourceFunction) {
        addSource(source, new TripleCombinatorObserver<>(this, secondSourceFunction, thirdSourceFunction));
    }
}