Search code examples
kotlinrx-java2rx-kotlin2

How to use RxJava2 combineLatest with a list of observables in Kotlin


I know how to do this in RxJava 2.

And I know how RxKotlin helps with similar issues.

But it seems that RxKotlin.Observables doesn't have this helper function for the list overload and I cannot figure it out. How would you do this?


Solution

  • Most static functions in RxJava are extension functions in RxKotlin. This particular function is an extension on Iterable<Observable<T>>. You can call it like this:

    listOfObservables.combineLatest { ... }