Represents a named unit of work with an asynchronous or synchronous execution function.

Tasks can be chained together in a scheduler to create complex workflows with proper data flow and error handling.

class LoadFileTask extends AcCmTask<string, ArrayBuffer> {
constructor() {
super('LoadFile')
}

async run(url: string): Promise<ArrayBuffer> {
const response = await fetch(url)
return response.arrayBuffer()
}
}

Type Parameters

  • TIn

    Input type for the task.

  • TOut

    Output type for the task.

Constructors

Properties

Methods

Constructors

  • Creates a new task with the specified name.

    Type Parameters

    • TIn
    • TOut

    Parameters

    • name: string

      The name identifier for this task.

    Returns AcCmTask<TIn, TOut>

Properties

name: string

Name of the task (for logging/debugging purposes)

Methods

  • Executes the task with the given input.

    This method must be implemented by subclasses to define the actual work performed by the task. Can return either a synchronous result or a Promise.

    Parameters

    • _input: TIn

      The input data for the task.

    Returns TOut | Promise<TOut>

    The task result, either synchronous or asynchronous.

    When the method is not implemented by a subclass.