map(_:)

When the current EventLoopFuture<Value> is fulfilled, run the provided callback, which performs a synchronous computation and returns a new value of type NewValue.

EventLoopFuture.swift:649
@preconcurrency func map<NewValue>(_ callback: @escaping (Value) -> (NewValue)) -> EventLoopFuture<NewValue>

Parameters

callback

Function that will receive the value of this EventLoopFuture and return a new value lifted into a new EventLoopFuture.

Returns

A future that will receive the eventual value.

Operations performed in map should not block, or they will block the entire event loop. map is intended for use when you have a data-driven function that performs a simple data transformation that cannot error.

If you have a data-driven function that can throw, you should use flatMapThrowing instead.

let future1 = eventually()
let future2 = future1.map { T -> U in
    ... stuff ...
    return u
}
let future3 = future2.map { U -> V in
    ... stuff ...
    return v
}