reduce(into:_:on:_:)

Returns a new EventLoopFuture that fires only when all the provided futures complete. The new EventLoopFuture contains the result of combining the initialResult with the values of the [EventLoopFuture<NewValue>]. This function is analogous to the standard library’s reduce(into:), which does not make copies of the result type for each EventLoopFuture.

EventLoopFuture.swift:1224
@preconcurrency static func reduce<InputValue>(into initialResult: Value, _ futures: [EventLoopFuture<InputValue>], on eventLoop: EventLoop, _ updateAccumulatingResult: @escaping (inout Value, InputValue) -> Void) -> EventLoopFuture<Value> where Value : Sendable, InputValue : Sendable

Parameters

initialResult

An initial result to begin the reduction.

futures

An array of EventLoopFuture to wait for.

eventLoop

The EventLoop on which the new EventLoopFuture callbacks will fire.

updateAccumulatingResult

The bifunction used to combine partialResults with new elements.

Returns

A new EventLoopFuture with the combined value.

The returned EventLoopFuture will fail as soon as a failure is encountered in any of the futures. However, the failure will not occur until all preceding EventLoopFutures have completed. At the point the failure is encountered, all subsequent EventLoopFuture objects will no longer be waited for. This function therefore fails fast: once a failure is encountered, it will immediately fail the overall EventLoopFuture.