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

//
// mapMany.swift
// RxSwiftExt
//
// Created by Joan Disho on 06/05/18.
// Copyright © 2018 RxSwift Community. All rights reserved.
//
import RxSwift
extension ObservableType where E: Collection {
/**
Projects each element of an observable collection into a new form.
- parameter transform: A transform function to apply to each element of the source collection.
- returns: An observable collection whose elements are the result of invoking the transform function on each element of source.
*/
public func mapMany<T>(_ transform: @escaping (E.Element) throws -> T) -> Observable<[T]> {
return map { collection -> [T] in
try collection.map(transform)
}
}
}