Instance Method
flatten(on:)
Converts a collection of
EventLoopFutures to an EventLoopFuture that wraps an array with the future values.func flatten<Value>(on eventLoop: any EventLoop) -> EventLoopFuture<[Value]> where Self.Element == EventLoopFuture<Value>
Parameters
eventLoopThe event-loop to succeed the futures on.
Return Value
The succeeded values in an array, wrapped in an EventLoopFuture.
Discussion
Acts as a helper for the EventLoop.flatten(_:[EventLoopFuture<Value>]) method.
let futures = [el.future(1), el.future(2), el.future(3), el.future(4)]
let flattened = futures.flatten(on: el)
// flattened: EventLoopFuture([1, 2, 3, 4])