Instance Method
flatten(_:)
Returns a new
EventLoopFuture that succeeds only when all the provided futures succeed. The new EventLoopFuture contains an array of results, maintaining same ordering as the futures.func flatten<T>(_ futures: [EventLoopFuture<T>]) -> EventLoopFuture<[T]>
Parameters
futuresAn array of futures to flatten into a single
EventLoopFuture.
Return Value
A new EventLoopFuture with all the resolved values of the input collection.
Discussion
The returned EventLoopFuture will fail if any of the provided futures fails. All remaining EventLoopFuture objects will be ignored.
See Also
EventLoop and EventLoopGroup
flatten(_:)Returns a newEventLoopFuturethat succeeds only when all the provided futures succeed, ignoring the resolved values.future()Creates a new, succeededEventLoopFuturefrom the worker’s event loop with aVoidvalue.future(error:)Creates a new, failedEventLoopFuturefrom the worker’s event loop.future(_:)Creates a new, succeededEventLoopFuturefrom the worker’s event loop.future(result:)Creates a newFuturefrom the worker’s event loop, succeeded or failed based on the inputResult.tryFuture(_:)An alternate name for this would befuture(catching:), but with that name, trailing closure syntax just looks likeel.future { ... }, which does not indicate to readers of the code that it is the error-capturing version. Since such an indication is highly desirable, a slightly less idiomatic name is used instead.