Instance Method
flatMapEachCompactThrowing(_:)
Calls a closure, which returns an
Optional, on each element in the sequence that is wrapped by an EventLoopFuture.func flatMapEachCompactThrowing<Result>(_ transform: @escaping (Value.Element) throws -> Result?) -> EventLoopFuture<[Result]>
Parameters
transformThe closure that each element in the sequence is passed into.
Return Value
A new EventLoopFuture that wraps the sequence of transformed elements.
Discussion
let collection = eventLoop.future(["one", "2", "3", "4", "five", "^", "7"])
let times2 = collection.mapEachCompact { int in
return Int(int)
}
// times2: EventLoopFuture([2, 3, 4, 7])
If your callback function throws, the returned EventLoopFuture will error.
See Also
EventLoopFuture
EventLoopFutureQueueAllows you to queue closures that produce anEventLoopFuture, so each future only gets run if the previous ones complete, succeed, or fail.mapEach(_:)Gets the value of a key path for each element in the sequence that is wrapped by anEventLoopFuture.mapEach(_:)Calls a closure on each element in the sequence that is wrapped by anEventLoopFuture.mapEachCompact(_:)Gets the optional value of a key path for each element in the sequence that is wrapped by anEventLoopFuture.mapEachCompact(_:)Calls a closure, which returns anOptional, on each element in the sequence that is wrapped by anEventLoopFuture.mapEachFlat(_:)Gets the collection value of a key path for each element in the sequence that is wrapped by anEventLoopFuture, combining the results into a single result collection.mapEachFlat(_:)Calls a closure which returns a collection on each element in the sequence that is wrapped by anEventLoopFuture, combining the results into a single result collection.flatMapEach(on:_:)Calls a closure, which returns anEventLoopFuture, on each element in a sequence that is wrapped by anEventLoopFuture. No results from each future are expected.flatMapEach(on:_:)Calls a closure, which returns anEventLoopFuture, on each element in a sequence that is wrapped by anEventLoopFuture.flatMapEachCompact(on:_:)Calls a closure, which returns anEventLoopFuture<Optional>, on each element in a sequence that is wrapped by anEventLoopFuture.flatMapEachThrowing(_:)Calls a closure on each element in the sequence that is wrapped by anEventLoopFuture.sequencedFlatMapEach(_:)An overload ofsequencedFlatMapEach(_:)which returns aVoidfuture instead of[Void]when the result type of the transform closure isVoid.sequencedFlatMapEach(_:)A variant form offlatMapEach(on:_:)which guarantees:sequencedFlatMapEachCompact(_:)Variant ofsequencedFlatMapEach(_:)which providescompactMap()semantics by allowing result values to benil. Such results are not included in the output array.whenTheySucceed(_:_:file:line:)Returns a newEventLoopFuturethat succeeds only if all of the provided fs succeed. The newEventLoopFuturewill contain all of the values fulfilled by the fs.