The zipWith operator

The instance version (that is, the copy of the function, which should be called with an instance rather than static) of the zip operator is zipWith, which can be called from the Observable instance itself. The only problem with this version is that you can pass only another source Observable. If you need to work with three or more Observable instances, you should rather consider using the zip operator instead of zipWith.

Here's an example:

    fun main(args: Array<String>) { 
      val observable1 = Observable.range(1,10) 
      val observable2 = listOf("String 1","String 2","String 3",      "String 4","String 5","String 6","String 7","String 8",      "String 9","String 10").toObservable() 
 
      observable1.zipWith(observable2,{e1:Int,e2:String -> 

Get Reactive Programming in Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.