FutureImpl
public class FutureImpl<Value> : ToFuture, Promise
An implementation of a future for managing and observing its value.
isFulfilled
A boolean property indicating whether the promise (and hence the future) has been fulfilled.
public var isFulfilled: Bool { get }
init(_:)
Initializes a new instance of FutureImpl
with an optional initial value.
public init(_ value: Value? = nil)
Parameters
value | The initial value of the future. If provided, the future is considered fulfilled immediately. |
resolve(_:)
Resolves the promise with a success value.
@discardableResult
public func resolve(_ value: Value) -> Future<Value>
Parameters
value | The value to resolve the promise with. |
Return Value
The future associated with the promise.
reject(_:)
Rejects the promise with an error.
@discardableResult
public func reject(_ error: Error) -> Future<Value>
Parameters
error | The error to reject the promise with. |
Return Value
The future associated with the promise.
toFuture()
Converts this instance into a Future
.
public func toFuture() -> Future<Value>
Return Value
A Future
representing the eventual result of the promise.