• Class decorator that automatically adds Multiple Future Container capabilities to a KOS model.

    This decorator eliminates the need for manual MultipleFutureHandler setup by:

    • Adding a futureHandler property for managing multiple concurrent Future operations
    • Adding reactive getters for default future, progress, status, isRunning, isCancelled (in full mode)
    • Adding dynamic named future getters based on

    Parameters

    • Optional options: KosMultipleFutureAwareOptions

      Configuration options for the decorator

    Returns ClassDecorator

    A class decorator

    Kos Future

    aliases

    • Adding cancelFuture method for canceling the default operation (in full mode)

    Important: Use TypeScript interface merging to get proper type information:

    // Add ESLint disable comment at top of file, then:
    interface MyModelImpl extends KosMultipleFutureAwareFull<"operation1" | "operation2"> {}

    @kosMultipleFutureAware()
    class MyModelImpl implements IKosDataModel {
    // All Future properties and named futures are now available with full type safety
    }

    Note: This decorator supports multiple concurrent Future operations. For models that only need single Future support, use

    Kos Future Aware

    instead.

    Example

    // Full mode example with multiple futures
    interface IceAgitatorModelImpl extends KosMultipleFutureAwareFull<"pour" | "agitate" | "gate"> {}

    @kosMultipleFutureAware()
    class IceAgitatorModelImpl implements IKosDataModel {
    get isPouring() {
    return !!(this.pourFuture && !this.pourFuture?.endState);
    }

    onFutureUpdate?(future: IFutureModel): void {
    // Handle Future updates from any operation
    }

    @kosFuture({ alias: "pour" })
    async pourIce(): Promise<void> {
    // Pour operation
    }

    @kosFuture({ alias: "agitate" })
    async testAgitate(): Promise<void> {
    // Agitation operation
    }
    }

    // Minimal mode example
    interface BackgroundServiceModelImpl extends KosMultipleFutureAwareMinimal<"task1" | "task2"> {}

    @kosMultipleFutureAware({ mode: 'minimal' })
    class BackgroundServiceModelImpl implements IKosDataModel {
    @kosFuture({ alias: "task1" })
    async backgroundTask1() {
    return "done";
    }

    @kosFuture({ alias: "task2" })
    async backgroundTask2() {
    return "done";
    }
    }

    Since

    2.0.0