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.

24 lines
682 B

5 years ago
  1. //
  2. // apply.swift
  3. // RxSwiftExt
  4. //
  5. // Created by Andy Chou on 2/22/17.
  6. // Copyright © 2017 RxSwift Community. All rights reserved.
  7. //
  8. import Foundation
  9. import RxSwift
  10. extension ObservableType {
  11. /// Apply a transformation function to the Observable.
  12. public func apply<T>(_ transform: (Observable<Self.E>) -> Observable<T>) -> Observable<T> {
  13. return transform(self.asObservable())
  14. }
  15. }
  16. extension PrimitiveSequenceType where TraitType == SingleTrait {
  17. /// Apply a transformation function to the Single.
  18. public func apply<T>(_ transform: (Single<Self.ElementType>) -> Single<T>) -> Single<T> {
  19. return transform(self.primitiveSequence)
  20. }
  21. }