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.

29 lines
879 B

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. //
  2. // materialized+elements.swift
  3. // RxSwiftExt
  4. //
  5. // Created by Andy Chou on 1/5/17.
  6. // Copyright © 2017 RxSwift Community. All rights reserved.
  7. //
  8. import Foundation
  9. import RxSwift
  10. extension ObservableType where Element: EventConvertible {
  11. /**
  12. Returns an observable sequence containing only next elements from its input
  13. - seealso: [materialize operator on reactivex.io](http://reactivex.io/documentation/operators/materialize-dematerialize.html)
  14. */
  15. public func elements() -> Observable<Element.Element> {
  16. return compactMap { $0.event.element }
  17. }
  18. /**
  19. Returns an observable sequence containing only error elements from its input
  20. - seealso: [materialize operator on reactivex.io](http://reactivex.io/documentation/operators/materialize-dematerialize.html)
  21. */
  22. public func errors() -> Observable<Swift.Error> {
  23. return compactMap { $0.event.error }
  24. }
  25. }