unwrap(orReplace:)

Unwrap an EventLoopFuture where its type parameter is an Optional.

EventLoopFuture.swift:1811
@preconcurrency func unwrap<NewValue>(orReplace replacement: NewValue) -> EventLoopFuture<NewValue> where Value == NewValue?, NewValue : Sendable

Parameters

replacement

the value of the returned EventLoopFuture when then resolved future’s value is Optional.some().

Returns

an new EventLoopFuture with new type parameter NewValue and the value passed in the replacement parameter.

Unwraps a future returning a new EventLoopFuture with either: the value passed in the orReplace parameter when the future resolved with value Optional.none, or the same value otherwise. For example:

promise.futureResult.unwrap(orReplace: 42).wait()