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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
package it.niedermann.android.reactivelivedata;
import androidx.annotation.NonNull;
import androidx.arch.core.util.Function;
import androidx.core.util.Consumer;
import androidx.core.util.Pair;
import androidx.core.util.Predicate;
import androidx.core.util.Supplier;
import androidx.lifecycle.LiveData;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.TimeUnit;
import kotlin.Triple;
import kotlin.jvm.functions.Function1;
/**
* Partial implementation of <a href="https://reactivex.io/documentation/operators.html">ReactiveX</a> features
*/
public interface ReactiveLiveDataBuilder<T> {
/**
* @see <a href="https://reactivex.io/documentation/operators/map.html">ReactiveX#map</a>
*/
@NonNull
<Y> ReactiveLiveDataBuilder<Y> map(@NonNull Function1<T, Y> mapFunction);
/**
* @see <a href="https://reactivex.io/documentation/operators/flatmap.html">ReactiveX#flatmap</a>
*/
@NonNull
<Y> ReactiveLiveDataBuilder<Y> flatMap(@NonNull Function1<T, LiveData<Y>> flatMapFunction);
/**
* @see #flatMap(Function1)
*/
@NonNull
<Y> ReactiveLiveDataBuilder<Y> flatMap(@NonNull Supplier<LiveData<Y>> flatMapSupplier);
/**
* @see <a href="https://reactivex.io/documentation/operators/distinct.html">ReactiveX#distinct</a>
*/
@NonNull
ReactiveLiveDataBuilder<T> distinctUntilChanged();
/**
* @see <a href="https://reactivex.io/documentation/operators/filter.html">ReactiveX#filter</a>
*/
@NonNull
ReactiveLiveDataBuilder<T> filter(@NonNull Predicate<T> predicate);
/**
* @see #filter(Predicate)
*/
@NonNull
ReactiveLiveDataBuilder<T> filter(@NonNull Supplier<Boolean> supplier);
/**
* @see <a href="https://reactivex.io/documentation/operators/do.html">ReactiveX#do</a>
*/
@NonNull
ReactiveLiveDataBuilder<T> tap(@NonNull Consumer<T> consumer);
/**
* @see #tap(Consumer)
*/
@NonNull
ReactiveLiveDataBuilder<T> tap(@NonNull Runnable runnable);
/**
* @see <a href="https://reactivex.io/documentation/operators/merge.html">ReactiveX#merge</a>
*/
@NonNull
ReactiveLiveData<T> merge(@NonNull Supplier<LiveData<T>> liveData);
/**
* @see <a href="https://reactivex.io/documentation/operators/take.html">ReactiveX#take</a>
*/
@NonNull
ReactiveLiveDataBuilder<T> take(int limit);
/**
* @see <a href="https://reactivex.io/documentation/operators/combinelatest.html">ReactiveX#combinelatest</a>
*/
@NonNull
<Y> ReactiveLiveDataBuilder<Pair<T, Y>> combineWith(@NonNull Function<T, LiveData<Y>> secondSourceFunction);
/**
* @see #combineWith(Function)
*/
@NonNull
<Y> ReactiveLiveDataBuilder<Pair<T, Y>> combineWith(@NonNull Supplier<LiveData<Y>> secondSourceSupplier);
/**
* @see <a href="https://reactivex.io/documentation/operators/combinelatest.html">ReactiveX#combinelatest</a>
*/
@NonNull
<Y, Z> ReactiveLiveDataBuilder<Triple<T, Y, Z>> combineWith(@NonNull Function<T, LiveData<Y>> secondSourceFunction, @NonNull Function<T, LiveData<Z>> thirdSourceFunction);
/**
* @see #combineWith(Function)
*/
@NonNull
<Y, Z> ReactiveLiveDataBuilder<Triple<T, Y, Z>> combineWith(@NonNull Function<T, LiveData<Y>> secondSourceFunction, @NonNull Supplier<LiveData<Z>> thirdSourceSupplier);
/**
* @see #combineWith(Function)
*/
@NonNull
<Y, Z> ReactiveLiveDataBuilder<Triple<T, Y, Z>> combineWith(@NonNull Supplier<LiveData<Y>> secondSourceSupplier, @NonNull Function<T, LiveData<Z>> thirdSourceFunction);
/**
* @see #combineWith(Function)
*/
@NonNull
<Y, Z> ReactiveLiveDataBuilder<Triple<T, Y, Z>> combineWith(@NonNull Supplier<LiveData<Y>> secondSourceSupplier, @NonNull Supplier<LiveData<Z>> thirdSourceSupplier);
/**
* @see <a href="https://reactivex.io/documentation/operators/debounce.html">ReactiveX#debounce</a>>
*/
@NonNull
ReactiveLiveDataBuilder<T> debounce(long timeout, @NonNull ChronoUnit timeUnit);
/**
* @param timeout defaults to {@link TimeUnit#MILLISECONDS}
*
* @see #debounce(long, ChronoUnit)
*/
@NonNull
ReactiveLiveDataBuilder<T> debounce(long timeout);
}
|