|
| 1 | +package io.reactivex.rxkotlin |
| 2 | + |
| 3 | +import io.reactivex.Flowable |
| 4 | +import io.reactivex.functions.* |
| 5 | +import org.reactivestreams.Publisher |
| 6 | + |
| 7 | + |
| 8 | +object Flowables { |
| 9 | + |
| 10 | + inline fun <T1,T2,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, crossinline combineFunction: (T1, T2) -> R) = |
| 11 | + Flowable.combineLatest(source1, source2, |
| 12 | + BiFunction<T1, T2, R> { t1, t2 -> combineFunction(t1,t2) })!! |
| 13 | + |
| 14 | + inline fun <T1,T2,T3,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>, crossinline combineFunction: (T1,T2, T3) -> R) = |
| 15 | + Flowable.combineLatest(source1, source2,source3, |
| 16 | + Function3{ t1: T1, t2: T2, t3: T3 -> combineFunction(t1,t2, t3) })!! |
| 17 | + |
| 18 | + inline fun <T1,T2,T3,T4,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>, |
| 19 | + source4: Flowable<T4>, crossinline combineFunction: (T1,T2, T3, T4) -> R) = |
| 20 | + Flowable.combineLatest(source1, source2,source3, source4, |
| 21 | + Function4 { t1: T1, t2: T2, t3: T3, t4: T4 -> combineFunction(t1,t2, t3, t4) })!! |
| 22 | + |
| 23 | + |
| 24 | + inline fun <T1,T2,T3,T4,T5,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, |
| 25 | + source3: Flowable<T3>, source4: Flowable<T4>, |
| 26 | + source5: Flowable<T5>, crossinline combineFunction: (T1,T2, T3, T4, T5) -> R) = |
| 27 | + Flowable.combineLatest(source1, source2,source3, source4, source5, |
| 28 | + Function5{ t1: T1, t2: T2, t3: T3, t4: T4, t5: T5 -> combineFunction(t1,t2, t3, t4, t5) })!! |
| 29 | + |
| 30 | + |
| 31 | + inline fun <T1,T2,T3,T4,T5,T6,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, |
| 32 | + source3: Flowable<T3>, source4: Flowable<T4>, |
| 33 | + source5: Flowable<T5>, source6: Flowable<T6>, crossinline combineFunction: (T1,T2, T3, T4, T5, T6) -> R) = |
| 34 | + Flowable.combineLatest(source1, source2,source3, source4, source5, source6, |
| 35 | + Function6 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6 -> combineFunction(t1,t2, t3, t4, t5, t6) })!! |
| 36 | + |
| 37 | + inline fun <T1,T2,T3,T4,T5,T6,T7,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, |
| 38 | + source3: Flowable<T3>, source4: Flowable<T4>, |
| 39 | + source5: Flowable<T5>, source6: Flowable<T6>, |
| 40 | + source7: Flowable<T7>, crossinline combineFunction: (T1,T2, T3, T4, T5, T6, T7) -> R) = |
| 41 | + Flowable.combineLatest(source1, source2,source3, source4, source5, source6, source7, |
| 42 | + Function7 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7 -> combineFunction(t1,t2, t3, t4, t5, t6, t7) })!! |
| 43 | + |
| 44 | + |
| 45 | + inline fun <T1,T2,T3,T4,T5,T6,T7,T8,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, |
| 46 | + source3: Flowable<T3>, source4: Flowable<T4>, |
| 47 | + source5: Flowable<T5>, source6: Flowable<T6>, |
| 48 | + source7: Flowable<T7>, source8: Flowable<T8>, |
| 49 | + crossinline combineFunction: (T1,T2, T3, T4, T5, T6, T7, T8) -> R) = |
| 50 | + Flowable.combineLatest(source1, source2,source3, source4, source5, source6, source7, source8, |
| 51 | + Function8 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8 -> combineFunction(t1,t2, t3, t4, t5, t6, t7, t8) })!! |
| 52 | + |
| 53 | + inline fun <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> combineLatest(source1: Flowable<T1>, source2: Flowable<T2>, |
| 54 | + source3: Flowable<T3>, source4: Flowable<T4>, |
| 55 | + source5: Flowable<T5>, source6: Flowable<T6>, |
| 56 | + source7: Flowable<T7>, source8: Flowable<T8>, |
| 57 | + source9: Flowable<T9>, crossinline combineFunction: (T1,T2, T3, T4, T5, T6, T7, T8, T9) -> R) = |
| 58 | + Flowable.combineLatest(source1, source2,source3, source4, source5, source6, source7, source8, source9, |
| 59 | + Function9 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9 -> combineFunction(t1,t2, t3, t4, t5, t6, t7, t8, t9) })!! |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + inline fun <T1,T2,R> zip(source1: Flowable<T1>, source2: Flowable<T2>, crossinline combineFunction: (T1, T2) -> R) = |
| 65 | + Flowable.zip(source1, source2, |
| 66 | + BiFunction<T1, T2, R> { t1, t2 -> combineFunction(t1,t2) })!! |
| 67 | + |
| 68 | + inline fun <T1,T2,T3,R> zip(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>, crossinline combineFunction: (T1,T2, T3) -> R) = |
| 69 | + Flowable.zip(source1, source2,source3, |
| 70 | + Function3 { t1: T1, t2: T2, t3: T3 -> combineFunction(t1,t2, t3) })!! |
| 71 | + |
| 72 | + inline fun <T1,T2,T3,T4,R> zip(source1: Flowable<T1>, source2: Flowable<T2>, source3: Flowable<T3>, source4: Flowable<T4>, crossinline combineFunction: (T1,T2, T3, T4) -> R) = |
| 73 | + Flowable.zip(source1, source2,source3, source4, |
| 74 | + Function4 { t1: T1, t2: T2, t3: T3, t4: T4 -> combineFunction(t1,t2, t3, t4) })!! |
| 75 | + |
| 76 | + inline fun <T1,T2,T3,T4,T5,R> zip(source1: Flowable<T1>, source2: Flowable<T2>, |
| 77 | + source3: Flowable<T3>, source4: Flowable<T4>, |
| 78 | + source5: Flowable<T5>, crossinline combineFunction: (T1,T2, T3, T4, T5) -> R) = |
| 79 | + Flowable.zip(source1, source2,source3, source4, source5, |
| 80 | + Function5{ t1: T1, t2: T2, t3: T3, t4: T4, t5: T5 -> combineFunction(t1,t2, t3, t4, t5) })!! |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + inline fun <T1,T2,T3,T4,T5,T6,R> zip(source1: Flowable<T1>, source2: Flowable<T2>, |
| 85 | + source3: Flowable<T3>, source4: Flowable<T4>, |
| 86 | + source5: Flowable<T5>, source6: Flowable<T6>, crossinline combineFunction: (T1,T2, T3, T4, T5, T6) -> R) = |
| 87 | + Flowable.zip(source1, source2,source3, source4, source5, source6, |
| 88 | + Function6 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6 -> combineFunction(t1,t2, t3, t4, t5, t6) })!! |
| 89 | + |
| 90 | + inline fun <T1,T2,T3,T4,T5,T6,T7,R> zip(source1: Flowable<T1>, source2: Flowable<T2>, |
| 91 | + source3: Flowable<T3>, source4: Flowable<T4>, |
| 92 | + source5: Flowable<T5>, source6: Flowable<T6>, |
| 93 | + source7: Flowable<T7>, crossinline combineFunction: (T1,T2, T3, T4, T5, T6, T7) -> R) = |
| 94 | + Flowable.zip(source1, source2,source3, source4, source5, source6, source7, |
| 95 | + Function7 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7 -> combineFunction(t1,t2, t3, t4, t5, t6, t7) })!! |
| 96 | + |
| 97 | + |
| 98 | + inline fun <T1,T2,T3,T4,T5,T6,T7,T8,R> zip(source1: Flowable<T1>, source2: Flowable<T2>, |
| 99 | + source3: Flowable<T3>, source4: Flowable<T4>, |
| 100 | + source5: Flowable<T5>, source6: Flowable<T6>, |
| 101 | + source7: Flowable<T7>, source8: Flowable<T8>, |
| 102 | + crossinline combineFunction: (T1,T2, T3, T4, T5, T6, T7, T8) -> R) = |
| 103 | + Flowable.zip(source1, source2,source3, source4, source5, source6, source7, source8, |
| 104 | + Function8 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8 -> combineFunction(t1,t2, t3, t4, t5, t6, t7, t8) })!! |
| 105 | + |
| 106 | + inline fun <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> zip(source1: Flowable<T1>, source2: Flowable<T2>, |
| 107 | + source3: Flowable<T3>, source4: Flowable<T4>, |
| 108 | + source5: Flowable<T5>, source6: Flowable<T6>, |
| 109 | + source7: Flowable<T7>, source8: Flowable<T8>, |
| 110 | + source9: Flowable<T9>, crossinline combineFunction: (T1,T2, T3, T4, T5, T6, T7, T8, T9) -> R) = |
| 111 | + Flowable.zip(source1, source2,source3, source4, source5, source6, source7, source8, source9, |
| 112 | + Function9 { t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9 -> combineFunction(t1,t2, t3, t4, t5, t6, t7, t8, t9) })!! |
| 113 | + |
| 114 | +} |
| 115 | + |
| 116 | +/** |
| 117 | + * An alias to [Flowable.withLatestFrom], but allowing for cleaner lambda syntax. |
| 118 | + */ |
| 119 | +inline fun <T, U, R> Flowable<T>.withLatestFrom(other: Publisher<U>, crossinline combiner: (T, U) -> R): Flowable<R> |
| 120 | + = withLatestFrom(other, BiFunction<T, U, R> { t, u -> combiner.invoke(t, u) }) |
| 121 | + |
| 122 | +/** |
| 123 | + * An alias to [Flowable.withLatestFrom], but allowing for cleaner lambda syntax. |
| 124 | + */ |
| 125 | +inline fun <T, T1, T2, R> Flowable<T>.withLatestFrom(o1: Publisher<T1>, o2: Publisher<T2>, crossinline combiner: (T, T1, T2) -> R): Flowable<R> |
| 126 | + = withLatestFrom(o1, o2, Function3 { t, t1, t2 -> combiner.invoke(t, t1, t2) }) |
| 127 | + |
| 128 | +/** |
| 129 | + * An alias to [Flowable.withLatestFrom], but allowing for cleaner lambda syntax. |
| 130 | + */ |
| 131 | +inline fun <T, T1, T2, T3, R> Flowable<T>.withLatestFrom(o1: Publisher<T1>, o2: Publisher<T2>, o3: Publisher<T3>, crossinline combiner: (T, T1, T2, T3) -> R): Flowable<R> |
| 132 | + = withLatestFrom(o1, o2, o3, Function4 { t, t1, t2, t3 -> combiner.invoke(t, t1, t2, t3) }) |
| 133 | + |
| 134 | +/** |
| 135 | + * An alias to [Flowable.withLatestFrom], but allowing for cleaner lambda syntax. |
| 136 | + */ |
| 137 | +inline fun <T, T1, T2, T3, T4, R> Flowable<T>.withLatestFrom(o1: Publisher<T1>, o2: Publisher<T2>, o3: Publisher<T3>, o4: Publisher<T4>, crossinline combiner: (T, T1, T2, T3, T4) -> R): Flowable<R> |
| 138 | + = withLatestFrom(o1, o2, o3, o4, Function5 { t, t1, t2, t3, t4 -> combiner.invoke(t, t1, t2, t3, t4) }) |
| 139 | + |
| 140 | +/** |
| 141 | + * An alias to [Flowable.zipWith], but allowing for cleaner lambda syntax. |
| 142 | + */ |
| 143 | +inline fun <T, U, R> Flowable<T>.zipWith(other: Publisher<U>, crossinline zipper: (T, U) -> R): Flowable<R> |
| 144 | + = zipWith(other, BiFunction { t, u -> zipper.invoke(t, u) }) |
0 commit comments