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

5 years ago
  1. //
  2. // mapMany.swift
  3. // RxSwiftExt
  4. //
  5. // Created by Joan Disho on 06/05/18.
  6. // Copyright © 2018 RxSwift Community. All rights reserved.
  7. //
  8. import RxSwift
  9. extension ObservableType where E: Collection {
  10. /**
  11. Projects each element of an observable collection into a new form.
  12. - parameter transform: A transform function to apply to each element of the source collection.
  13. - returns: An observable collection whose elements are the result of invoking the transform function on each element of source.
  14. */
  15. public func mapMany<T>(_ transform: @escaping (E.Element) throws -> T) -> Observable<[T]> {
  16. return map { collection -> [T] in
  17. try collection.map(transform)
  18. }
  19. }
  20. }