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
532 B

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<T>() -> Observable<T> where E == T? {
  16. return self.filter { $0 != nil }.map { $0! }
  17. }
  18. }