Instance Method
optionalFlatMap(_:)
Calls a closure on an optional value in an
EventLoopFuture if it exists.func optionalFlatMap<Wrapped, Result>(_ closure: @escaping (Wrapped) -> EventLoopFuture<Result>) -> EventLoopFuture<Result?> where Value == Wrapped?
Parameters
closureThe closure to call on the unwrapped optional value.
Return Value
The result of the closure if the optional was unwrapped, or nil if it wasn’t, wrapped in an EventLoopFuture.
Discussion
let optional = eventLoop.future(Optiona<Int>.some(42))
let some = optional.optionalFlatMap { int -> EventLoopFuture<Float> in
return int * 3.14
}
// some: EventLoopFuture(Optional(131.88))