What is Async.Executor?
Async.Executor is an object that wraps a piece of code to be executed asynchronously in Async.
Fundamentally, Async.Executor is a Func object that has resolve
and reject
methods.
Async.Executor is an object that wraps a piece of code to be executed asynchronously in Async.
Fundamentally, Async.Executor is a Func object that has resolve
and reject
methods.
public class HelloWorldExecutor extends Async.Executor {
public HelloWorldExecutor() {
super(0);
}
public override Object exec() {
this.resolve('HelloWorld');
}
}
Async promise = new Async(new HelloWorldExecutor());
Most of the time we can use a Func as a simplified Async.Executor.
public class HelloWorldFunc extends Func {
public HelloWorldFunc() {
super(0);
}
public override Object exec() {
return 'HelloWorld';
}
}
Async promise = new Async(new HelloWorldFunc());
Contribute on Github! Edit this section.