These are chat archives for ReactiveX/RxJava

19th
May 2018
Steven Lang
@steven-lang
May 19 2018 08:20
Can somebody give me a hint why Observable.zip does not accept my parameters in the following situation: https://gist.github.com/slang03/6898804b3600a6aabc7a1c14a4e18265 ?
Ignacio Baca Moreno-Torres
@ibaca
May 19 2018 09:43
zip operator with a iterator or an array of sources expect a Array<Any> -> T function
Ignacio Baca Moreno-Torres
@ibaca
May 19 2018 09:50
val jobs: Iterable<Observable<List<Int>>> = (0 until 40 step 10)
        .map { Observable.fromArray(listOf(it + 1, it + 2, it + 3)) }
        .asIterable()
Observable.zip(jobs, { n -> n.flatMap { it as List<*> } }).forEach { println(it) }
[1, 2, 3, 11, 12, 13, 21, 22, 23, 31, 32, 33]
Steven Lang
@steven-lang
May 19 2018 09:51
That makes sense
And works! Thanks
Ignacio Baca Moreno-Torres
@ibaca
May 19 2018 09:51
:raised_hands:
Ignacio Baca Moreno-Torres
@ibaca
May 19 2018 09:59
uhm, just in case, maybe you are trying to do this…
val jobs = (0 until 40 step 10).map { fromArray(it + 1, it + 2, it + 3) }
Observable.zip(jobs, { it.map { it as Int }.toList() }).forEach { println(it) }
// [1, 11, 21, 31]
// [2, 12, 22, 32]
// [3, 13, 23, 33]