Extracted this out into a function that seems to w...
# rx
k
Extracted this out into a function that seems to work OK (for the 3 source observable variant anyway):
Copy code
fun <T1, T2, T3, R> asyncCombineLatest(o1: Observable<T1>,
                                                   o2: Observable<T2>,
                                                   o3: Observable<T3>,
                                                   asyncCombineFunc: (T1, T2, T3) -> Observable<R>): Observable<R> =
            Observable.combineLatest(o1, o2, o3) { a, b, c -> Triple(a, b, c) }
                    .flatMap { bundle ->
                        val (a, b, c) = bundle
                        asyncCombineFunc(a, b, c)
                    }
m
You can improve it a bit:
.flatMap { (a, b, c) ->
if you are on K 1.1.
👍 2
k
thanks.. sadly we're not yet
a
Why not an extension function of Observable?
also, you could just:
Copy code
Observable.combineLatest(o1, o2, o3, { a, b, c -> asyncCombineFunc(a, b, c) })
    .flatMap { it }
Instead of all this packing and unpacking
(better yet,
Observable.combineLatest(o1, o2, o3, this::asyncCombineFunc).flatMap { it }
w. 1.1 =)
👍 1
k
much nicer. Thanks for the snippet @alex.hart