Skip to content

Instance Method

mapEachFlat(_:)

Gets the collection value of a key path for each element in the sequence that is wrapped by an EventLoopFuture, combining the results into a single result collection.
func mapEachFlat<ResultSegment>(_ keyPath: KeyPath<Value.Element, ResultSegment>) -> EventLoopFuture<[ResultSegment.Element]> where ResultSegment : Sequence

Parameters

keyPath

The key path to access on each element in the sequence.

Return Value

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

Discussion

let collection = eventLoop.future(["ABC", "👩‍👩‍👧‍👧"])
let flat = collection.mapEachFlat(\.utf8CString)
// flat: [65, 66, 67, 0, -16, -97, -111, -87, -30, -128, -115, -16, -97, -111, -87, -30,
//        -128, -115, -16, -97, -111, -89, -30, -128, -115, -16, -97, -111, -89, 0]