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

5 years ago
5 years ago
5 years ago
5 years ago
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 Element: 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<Result>(_ transform: @escaping (Element.Element) throws -> Result) -> Observable<[Result]> {
  16. return map { collection -> [Result] in
  17. try collection.map(transform)
  18. }
  19. }
  20. }