Two methods that would come in very handy for handling futures that need to be run one after another:
[() -> EventLoopFuture<T>].syncFlatten(on: EventLoop) -> EventLoopFuture<[T]>:
Flattens out the array of EventLoopFuture if they all succeed, similar to [EventLoopFuture<T>].flatten(on:), but instead each future from a closure must succeed before the next closure is called and the result of the future added the resulting array.
EventLoop.reduce(_: [() -> EventLoopFuture<T>], onSuccess: (T) throws -> ()) -> EventLoopFuture<Void>:
Iterates over the lazy futures that are passed in. As each one succeeds, the onSuccess closure is called with the resulting value and then the next lazy future in the array is called. When all the calls succeed (or one fails), the result will be returned from the method in an EventLoopFuture<Void>.
Two methods that would come in very handy for handling futures that need to be run one after another:
[() -> EventLoopFuture<T>].syncFlatten(on: EventLoop) -> EventLoopFuture<[T]>
: Flattens out the array ofEventLoopFuture
if they all succeed, similar to[EventLoopFuture<T>].flatten(on:)
, but instead each future from a closure must succeed before the next closure is called and the result of the future added the resulting array.EventLoop.reduce(_: [() -> EventLoopFuture<T>], onSuccess: (T) throws -> ()) -> EventLoopFuture<Void>
: Iterates over the lazy futures that are passed in. As each one succeeds, theonSuccess
closure is called with the resulting value and then the next lazy future in the array is called. When all the calls succeed (or one fails), the result will be returned from the method in anEventLoopFuture<Void>
.