Functions
The following functions are available globally.
-
Shorthand for creating a new
Future<Value>.Note that the callback provided to this method will execute on the provided dispatch queue.
Declaration
Swift
public func promise<Value>(on queue: DispatchQueue = .futures, _ body: @escaping () throws -> Value) -> Future<Value>Parameters
queueDispatch queue to execute the callback on.
bodyFunction that returns a value, assigned to the future returned by this function.
Return Value
A future that will receive the eventual value.
-
Shorthand for creating a new
Future<Value>, in an asynchronous fashion.Note that the callback provided to this method will execute on the provided dispatch queue.
Declaration
Swift
public func promise<Value>( _ type: Value.Type, on queue: DispatchQueue = .futures, _ body: @escaping (@escaping (_ value: Result<Value, Error>) -> Void) throws -> Void) -> Future<Value>Parameters
typeType of the future value.
queueDispatch queue to execute the callback on.
bodyA function with a completion function as its parameter, taking a
Result<Value, Error>, which will be used to resolve the future returned by this method.valueResult<Value, Error>to resolve the future with.Return Value
A future that will receive the eventual value.
View on GitHub
Functions Reference