Class AcCmTaskScheduler<TInitial, TFinal>

Type-safe task scheduler that executes a chain of named tasks in order.

The scheduler passes results between tasks, reports progress, and stops execution on the first failure. Supports both synchronous and asynchronous tasks.

// Create scheduler with string input and object output
const scheduler = new AcCmTaskScheduler<string, ParsedData>()

// Add tasks
scheduler.addTask(new LoadFileTask())
scheduler.addTask(new ParseDataTask())
scheduler.addTask(new ValidateDataTask())

// Set callbacks
scheduler.setProgressCallback((progress, task) => {
console.log(`${task.name}: ${(progress * 100).toFixed(1)}%`)
})

scheduler.setCompleteCallback((result) => {
console.log('All tasks completed:', result)
})

// Execute
await scheduler.execute('file.dwg')

Type Parameters

  • TInitial

    Initial input type for the first task.

  • TFinal = TInitial

    Final output type from the last task.

Constructors

Methods

  • Adds a task to the execution queue.

    Type Parameters

    • TIn
    • TOut

    Parameters

    Returns void

  • Starts execution of the task queue with the given initial input.

    Parameters

    Returns Promise<void>

  • Sets a callback to be called if any task throws an error.

    Parameters

    • callback: AcCmErrorCallback

    Returns void

  • Sets a callback to receive progress updates.

    Parameters

    • callback: AcCmProgressCallback

    Returns void