RXSwift Zip 运算符 N 项通过可枚举
RXSwift Zip operator N items via an enumerable
我正在使用 RxSwift 的 zip
operator to combine Observable
items. I want to combine more than 8 (the max currently supported). Does RxSwift have a zip
operator similar to RxJava? - RxJava Zip Operator Documentation
CollectionType
.
使用的话可以处理8个以上
extension CollectionType where Generator.Element : ObservableType {
public func zip<R>(resultSelector: [Generator.Element.E] throws -> R) -> Observable<R> {
return ZipCollectionType(sources: self, resultSelector: resultSelector)
}
}
所以不要像这样使用它:
Observable.zip(o1, o2, o3, o4, o5, o6, o7, o8, o9) { ... }
这样使用:
[o1, o2, o3, o4, o5, o6, o7, o8, o9].zip { ... }
我正在使用 RxSwift 的 zip
operator to combine Observable
items. I want to combine more than 8 (the max currently supported). Does RxSwift have a zip
operator similar to RxJava? - RxJava Zip Operator Documentation
CollectionType
.
extension CollectionType where Generator.Element : ObservableType {
public func zip<R>(resultSelector: [Generator.Element.E] throws -> R) -> Observable<R> {
return ZipCollectionType(sources: self, resultSelector: resultSelector)
}
}
所以不要像这样使用它:
Observable.zip(o1, o2, o3, o4, o5, o6, o7, o8, o9) { ... }
这样使用:
[o1, o2, o3, o4, o5, o6, o7, o8, o9].zip { ... }