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

    This decorator eliminates the need for manual Future Container setup by:

    • Adding a futureHandler property for managing Future operations
    • Adding reactive getters for future, progress, status, isRunning, isCancelled (in full mode)
    • Adding cancelFuture method for canceling operations (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 KosFutureAwareFull<MyDataType> {}

    kosFutureAware()
    class MyModelImpl implements IKosDataModel {
    // All Future properties are now available with full type safety
    }

    Note: This decorator supports single Future operations. For models that need to manage multiple concurrent Futures, use

    Parameters

    • Optional options: KosFutureAwareOptions

      Configuration options for the decorator

    Returns ClassDecorator

    A class decorator

    Kos Multi Future Aware

    (coming soon).

    Example

    // Full mode example
    interface DeviceOperationsModelImpl extends KosFutureAwareFull<OperationData> {}

    kosFutureAware()
    class DeviceOperationsModelImpl implements IKosDataModel {
    onFutureUpdate?(future: IFutureModel<OperationData>): void {
    // Handle Future updates
    }

    kosFuture()
    async performOperation(): Promise<OperationData> {
    return { result: "done" };
    }
    }

    // Minimal mode example
    interface BackgroundServiceModelImpl extends KosFutureAwareMinimal {}

    kosFutureAware({ mode: 'minimal' })
    class BackgroundServiceModelImpl implements IKosDataModel {
    kosFuture()
    async backgroundTask() {
    return "done";
    }
    }

    Since

    2.0.0