Skip to content

Instance Method

mapEachFlat(_:)

Calls a closure which returns a collection on each element in the sequence that is wrapped by an EventLoopFuture, combining the results into a single result collection.
func mapEachFlat<ResultSegment>(_ transform: @escaping (Value.Element) -> ResultSegment) -> EventLoopFuture<[ResultSegment.Element]> where ResultSegment : Sequence

Parameters

transform

The closure that each element in the sequence is passed into.

Return Value

A new EventLoopFuture that wraps the flattened sequence of transformed elements.

Discussion

let collection = eventLoop.future([[1, 2, 3], [9, 8, 7], [], [0]])
let flat = collection.mapEachFlat { $0 }
// flat: [1, 2, 3, 9, 8, 7, 0]

See Also

EventLoopFuture