我正在使用RxSwift的zip
操作符來合併Observable
項目。我想結合超過8(目前支持的最大值)。 RxSwift是否有與RxJava類似的zip
運算符? - RxJava Zip Operator DocumentationRXSwift Zip操作符通過枚舉的N個項目
3
A
回答
3
如果您在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 { ... }
+0
這很有趣,有沒有任何副作用? –
+0
沒有副作用。它的行爲就像'Observable.zip'。 – solidcell
+0
如果我正在閱讀該權利,它會將該集合視爲一組源觀察對象,然後在它們散發時將它們拉動?那是對的嗎? –
相關問題
- 1. 通過stcmd.exe枚舉StarTeam項目
- 2. 如何通過項目之間的任意增量枚舉枚舉
- 3. 如何使一個枚舉項目具有另一個枚舉的項目?
- 4. 迭代n到Ruby枚舉中的最後一個項目
- 5. 如何將字符串項目放在一個枚舉枚舉的枚舉映射的字符串?
- 6. 通過動態對象的Office互操作的枚舉值
- 7. 枚舉Objective-C和「<<」操作符
- 8. C++通過枚舉
- 9. 通過枚舉名字符串獲取枚舉值
- 10. 在枚舉和位操作
- 11. UWP組合框:通過枚舉的項目源人口
- 12. MYSQL - 哪個枚舉執行更好的枚舉('Y','N')或枚舉('1','0')
- 13. NSArray的枚舉通過組
- 14. 通過指針枚舉NSString字符
- 15. 如何通過枚舉作爲參數
- 16. 通過枚舉循環作爲參數
- 17. C++通過枚舉作爲參數
- 18. 定期Java項目枚舉
- 19. Webdav:枚舉目錄項
- 20. 如何枚舉PropertyGrid項目?
- 21. 我怎麼能枚舉一個項目
- 22. 枚舉通過使用JavaScript
- 23. 如何通過IDictionary枚舉
- 24. 枚舉通過Dictionary.KeyCollection爲了
- 25. 查詢通過枚舉RavenDB
- 26. 通過枚舉例外 - Java
- 27. 通過枚舉參數
- 28. 枚舉通過數據源
- 29. JPQL通過枚舉排序
- 30. 通過枚舉浮點數
所以做了回答以下滿足你的問題?我不確定你爲什麼不接受它。 – solidcell