Skip to content

Instance Method

mapEachCompact(_:)

Gets the optional value of a key path for each element in the sequence that is wrapped by an EventLoopFuture.
func mapEachCompact<Result>(_ keyPath: KeyPath<Value.Element, Result?>) -> EventLoopFuture<[Result]>

Parameters

keyPath

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

Return Value

A new EventLoopFuture that wraps the sequence of non-nil key path values.

Discussion

let collection = eventLoop.future(["asdf", "qwer", "zxcv", ""])
let letters = collection.mapEachCompact(\.first)
// letters: EventLoopFuture(["a", "q", "z"])