flatten(on:)
Converts a collection of EventLoopFuture
s to an EventLoopFuture
that wraps an array with the future values.
func flatten<Value>(on eventLoop: EventLoop) -> EventLoopFuture<[Value]> where Self.Element == EventLoopFuture<Value>
Parameters
- eventLoop
The event-loop to succeed the futures on.
Returns
The succeeded values in an array, wrapped in an EventLoopFuture
.
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])