@@ -13,10 +13,24 @@ object Observables {
1313 Observable .combineLatest(source1, source2,
1414 BiFunction <T1 , T2 , R > { t1, t2 -> combineFunction(t1,t2) })!!
1515
16+ /* *
17+ * Emits `Pair<T1,T2>`
18+ */
19+ fun <T1 ,T2 > combineLatest (source1 : Observable <T1 >, source2 : Observable <T2 >) =
20+ Observable .combineLatest(source1, source2,
21+ BiFunction <T1 , T2 , Pair <T1 ,T2 >> { t1, t2 -> t1 to t2 })!!
22+
1623 inline fun <T1 ,T2 ,T3 ,R > combineLatest (source1 : Observable <T1 >, source2 : Observable <T2 >, source3 : Observable <T3 >, crossinline combineFunction : (T1 ,T2 , T3 ) -> R ) =
1724 Observable .combineLatest(source1, source2,source3,
1825 Function3 { t1: T1 , t2: T2 , t3: T3 -> combineFunction(t1,t2, t3) })!!
1926
27+ /* *
28+ * Emits `Triple<T1,T2,T3>`
29+ */
30+ fun <T1 ,T2 ,T3 > combineLatest (source1 : Observable <T1 >, source2 : Observable <T2 >, source3 : Observable <T3 >) =
31+ Observable .combineLatest(source1, source2, source3,
32+ Function3 <T1 , T2 , T3 , Triple <T1 ,T2 ,T3 >> { t1, t2, t3 -> Triple (t1,t2,t3) })!!
33+
2034 inline fun <T1 ,T2 ,T3 ,T4 ,R > combineLatest (source1 : Observable <T1 >, source2 : Observable <T2 >, source3 : Observable <T3 >,
2135 source4 : Observable <T4 >, crossinline combineFunction : (T1 ,T2 , T3 , T4 ) -> R ) =
2236 Observable .combineLatest(source1, source2,source3, source4,
@@ -67,10 +81,25 @@ object Observables {
6781 Observable .zip(source1, source2,
6882 BiFunction <T1 , T2 , R > { t1, t2 -> combineFunction(t1,t2) })!!
6983
84+
85+ /* *
86+ * Emits `Pair<T1,T2>`
87+ */
88+ fun <T1 ,T2 > zip (source1 : Observable <T1 >, source2 : Observable <T2 >) =
89+ Observable .zip(source1, source2,
90+ BiFunction <T1 , T2 , Pair <T1 ,T2 >> { t1, t2 -> t1 to t2 })!!
91+
7092 inline fun <T1 ,T2 ,T3 ,R > zip (source1 : Observable <T1 >, source2 : Observable <T2 >, source3 : Observable <T3 >, crossinline combineFunction : (T1 ,T2 , T3 ) -> R ) =
7193 Observable .zip(source1, source2,source3,
7294 Function3 { t1: T1 , t2: T2 , t3: T3 -> combineFunction(t1,t2, t3) })!!
7395
96+ /* *
97+ * Emits `Triple<T1,T2,T3>`
98+ */
99+ fun <T1 ,T2 ,T3 > zip (source1 : Observable <T1 >, source2 : Observable <T2 >, source3 : Observable <T3 >) =
100+ Observable .zip(source1, source2, source3,
101+ Function3 <T1 , T2 , T3 , Triple <T1 ,T2 ,T3 >> { t1, t2, t3 -> Triple (t1,t2,t3) })!!
102+
74103 inline fun <T1 ,T2 ,T3 ,T4 ,R > zip (source1 : Observable <T1 >, source2 : Observable <T2 >, source3 : Observable <T3 >, source4 : Observable <T4 >, crossinline combineFunction : (T1 ,T2 , T3 , T4 ) -> R ) =
75104 Observable .zip(source1, source2,source3, source4,
76105 Function4 { t1: T1 , t2: T2 , t3: T3 , t4: T4 -> combineFunction(t1,t2, t3, t4) })!!
@@ -122,12 +151,21 @@ object Observables {
122151inline fun <T , U , R > Observable<T>.withLatestFrom (other : ObservableSource <U >, crossinline combiner : (T , U ) -> R ): Observable <R >
123152 = withLatestFrom(other, BiFunction <T , U , R > { t, u -> combiner.invoke(t, u) })
124153
154+ /* *
155+ * Emits a `Pair`
156+ */
157+ inline fun <T , U , R > Observable<T>.withLatestFrom (other : ObservableSource <U >): Observable <Pair <T ,U >>
158+ = withLatestFrom(other, BiFunction { t, u -> Pair (t,u) })
159+
125160/* *
126161 * An alias to [Observable.withLatestFrom], but allowing for cleaner lambda syntax.
127162 */
128163inline fun <T , T1 , T2 , R > Observable<T>.withLatestFrom (o1 : ObservableSource <T1 >, o2 : ObservableSource <T2 >, crossinline combiner : (T , T1 , T2 ) -> R ): Observable <R >
129164 = withLatestFrom(o1, o2, Function3 <T , T1 , T2 , R > { t, t1, t2 -> combiner.invoke(t, t1, t2) })
130165
166+ inline fun <T , T1 , T2 > Observable<T>.withLatestFrom (o1 : ObservableSource <T1 >, o2 : ObservableSource <T2 >): Observable <Triple <T ,T1 ,T2 >>
167+ = withLatestFrom(o1, o2, Function3 { t, t1, t2 -> Triple (t, t1, t2) })
168+
131169/* *
132170 * An alias to [Observable.withLatestFrom], but allowing for cleaner lambda syntax.
133171 */
@@ -146,3 +184,8 @@ inline fun <T, T1, T2, T3, T4, R> Observable<T>.withLatestFrom(o1: ObservableSou
146184inline fun <T , U , R > Observable<T>.zipWith (other : ObservableSource <U >, crossinline zipper : (T , U ) -> R ): Observable <R >
147185 = zipWith(other, BiFunction { t, u -> zipper.invoke(t, u) })
148186
187+ /* *
188+ * Emits a zipped `Pair`
189+ */
190+ inline fun <T , U > Observable<T>.zipWith (other : ObservableSource <U >): Observable <Pair <T ,U >>
191+ = zipWith(other, BiFunction { t, u -> Pair (t,u) })
0 commit comments