Skip to main content
Version: SDK 5.0.x

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

valueThe 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

valueThe 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

errorThe 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.