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.

25 lines
747 B

5 years ago
5 years ago
5 years ago
5 years ago
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<Result>(_ transform: (Observable<Element>) -> Observable<Result>) -> Observable<Result> {
  13. return transform(self.asObservable())
  14. }
  15. }
  16. extension PrimitiveSequenceType {
  17. /// Apply a transformation function to the primitive sequence.
  18. public func apply<Result>(_ transform: (PrimitiveSequence<Trait, Element>) -> PrimitiveSequence<Trait, Result>)
  19. -> PrimitiveSequence<Trait, Result> {
  20. return transform(self.primitiveSequence)
  21. }
  22. }