1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-28 02:54:31 +03:00
vimr/VimR/RxSwiftCommons.swift

29 lines
589 B
Swift
Raw Normal View History

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
2016-08-03 22:41:43 +03:00
import Cocoa
import RxSwift
extension Array {
/// This method only makes sense for `Array<Observable<Any>>`.
/// - Returns: Merged observables
func toMergedObservables() -> Observable<Any> {
2016-09-25 19:10:07 +03:00
return Observable
.from(self.flatMap { $0 as? Observable<Any> })
.flatMap { $0 }
}
}
extension ObservableType {
func mapOmittingNil<R>(_ transform: @escaping (Self.E) throws -> R?) -> RxSwift.Observable<R> {
return self
.map(transform)
.filter { $0 != nil }
.map { $0! }
}
}