Future handler for managing multiple concurrent long-running operations.

Provides comprehensive lifecycle management for models that coordinate multiple device operations simultaneously. Each Future is tracked with its own alias and receives automatic progress updates and cleanup when operations complete.

Example: Managing Multiple Operations

@kosModel("device-maintenance-model")
export class DeviceMaintenanceModel implements FutureContainer {
futureHandler: MultipleFutureHandler;

constructor(modelId: string, options: any, context: KosCreationContext) {
this.id = modelId;
this.futureHandler = new MultipleFutureHandler(this);
}

async startCalibration(deviceId: string): Promise<CalibrationResult> {
const future = await this.createFuture('/device/calibrate', { deviceId });
this.futureHandler.addFuture(future, `calibration-${deviceId}`);
return future;
}

async startCleaning(deviceId: string): Promise<CleaningResult> {
const future = await this.createFuture('/device/clean', { deviceId });
this.futureHandler.addFuture(future, `cleaning-${deviceId}`);
return future;
}

onFutureUpdate(future: IFutureModel): void {
// Handle progress updates from any managed Future
console.log(`${future.id}: ${future.progress}% complete`);
}
}

Type Parameters

  • T extends {} = Record<string, unknown>

Implements