Created
July 8, 2016 10:09
-
-
Save ukitaka/ca117bc3bf3db83fcdf336b1d25e8248 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol OptionalType { | |
associatedtype Wrapped | |
func map<U>(@noescape f: (Wrapped) throws -> U) rethrows -> U? | |
} | |
extension Optional: OptionalType { | |
} | |
extension ObservableType where E: OptionalType { | |
func filterNil() -> Observable<E.Wrapped> { | |
return self.flatMap { $0.map { Observable.just($0) } ?? Observable.empty() } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment