You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
538 B

5 years ago
5 years ago
5 years ago
  1. //
  2. // unwrap.swift
  3. // RxSwiftExt
  4. //
  5. // Created by Marin Todorov on 4/7/16.
  6. // Copyright © 2016 RxSwift Community. All rights reserved.
  7. //
  8. import Foundation
  9. import RxSwift
  10. extension ObservableType {
  11. /**
  12. Takes a sequence of optional elements and returns a sequence of non-optional elements, filtering out any nil values.
  13. - returns: An observable sequence of non-optional elements
  14. */
  15. public func unwrap<Result>() -> Observable<Result> where Element == Result? {
  16. return self.compactMap { $0 }
  17. }
  18. }