2016-07-27 19:22:25 +03:00
|
|
|
/**
|
|
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
|
|
* See LICENSE
|
|
|
|
*/
|
|
|
|
|
2016-08-03 22:41:43 +03:00
|
|
|
import Cocoa
|
2016-07-27 19:22:25 +03:00
|
|
|
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> })
|
2016-07-27 19:22:25 +03:00
|
|
|
.flatMap { $0 }
|
|
|
|
}
|
|
|
|
}
|
2016-12-27 11:32:55 +03:00
|
|
|
|
|
|
|
extension ObservableType {
|
|
|
|
|
|
|
|
func mapOmittingNil<R>(_ transform: @escaping (Self.E) throws -> R?) -> RxSwift.Observable<R> {
|
|
|
|
return self
|
|
|
|
.map(transform)
|
|
|
|
.filter { $0 != nil }
|
|
|
|
.map { $0! }
|
|
|
|
}
|
|
|
|
}
|