RunAsync
Executes the given code asynchronously and returns to you a BoxFuture object which inherits from CompletableFuture.
This way you can create fluent asynchronous code that can be chained and composed.
Method Signature
RunAsync(callback=[function], executor=[any])Arguments
Argument
Type
Required
Description
Default
callback
function
true
The code to execute asynchronously, this can be a closure or lambda.
executor
any
false
The executor to use for the asynchronous execution. This can be an instance of an Executor class, or the name of a registered executor in the AsyncService.
Examples
Run a function asynchronously and get the result
future = runAsync( () => {
return "Hello World!";
} );
writeOutput( future.get() );
Result: Hello World!
Run a function after the asynchronous function and use a five milliseconds timeout when calling get()
Result: 5
Run a function asynchronously with then() and error()
Result: 7
Additional Examples
Related
Last updated
Was this helpful?
