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
queue
Dispatch queue to execute the callback on.
body
Function 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
type
Type of the future value.
queue
Dispatch queue to execute the callback on.
body
A 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.value
Result<Value, Error>
to resolve the future with.Return Value
A future that will receive the eventual value.