In RxScala how to "zip" more than 2 Observables?
val ob1: Observable[Int] = Observable.from(Future(10))
val ob2: Observable[Int] = Observable.from(Future(20))
val ob3: Observable[Int] = Observable.from(Future(30))
"zip" works perfect with 2 Observables
val obComb: Observable[(Int, Int, Int)] = ob1 zip ob2
How do we "zip" more than 2 Observables?
You can use zipWith
which lets you provide your "zipping" function.
val obComb = ob1
.zipWith(ob2)({ case (x1, x2) => (x1, x2) })
.zipWith(ob3)({ case ((x1, x2), x3) => (x1, x2, x3) })