Async.apex

  • Docs
  • Tutorials
Docs Menu
  • Async
  • Methods
  • Executor

Executor Guide

Async Executor

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.

How to Create an Async.Executor?

public class HelloWorldExecutor extends Async.Executor {
    public HelloWorldExecutor() {
        super(0);
    }

    public override Object exec() {
        this.resolve('HelloWorld');
    }
}

Async promise = new Async(new HelloWorldExecutor());

Simplified Async.Executor

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.