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.

22 lines
657 B

5 years ago
  1. //
  2. // mapAt.swift
  3. // RxSwiftExt
  4. //
  5. // Created by Michael Avila on 2/8/18.
  6. // Copyright © 2018 RxSwift Community. All rights reserved.
  7. //
  8. import RxSwift
  9. extension ObservableType {
  10. /**
  11. Returns an observable sequence containing as many elements as its input but all of them are mapped to the result at the given keyPath
  12. - parameter keyPath: A key path whose root type matches the element type of the input sequence
  13. - returns: An observable squence containing the values pointed to by the key path
  14. */
  15. public func mapAt<R>(_ keyPath: KeyPath<E, R>) -> Observable<R> {
  16. return self.map { $0[keyPath: keyPath] }
  17. }
  18. }