RxSwift: Use Zip with different type observables

前端 未结 3 1817
误落风尘
误落风尘 2021-02-14 05:28

I\'m using RxSwift 2.0.0-beta

How can I combine 2 observables of different types in a zip like manner?

// This works
[just(1), just(1)].zip { intElement         


        
3条回答
  •  时光取名叫无心
    2021-02-14 05:54

    Here is how to make it work for RxSwift 2.3+

    Observable.zip(Observable.just(1), Observable.just("!")) {
        return ($0, $1)
    }
    

    or

    Observable.zip(Observable.just(1), Observable.just("!")) {
        return (anyName0: $0, anyName1: $1)
    }
    

提交回复
热议问题