Base interface providing common container-aware methods and properties. Used internally by both KosContainerAware and KosContainerAwareWithProp.

interface KosContainerAwareBase<T> {
    getModel(id): undefined | T;
    addModel(model): void;
    removeModel(id): void;
    addAll(models): void;
    removeAll(ids): void;
    removeAndDestroy(id): Promise<void>;
    removeAndDestroyAll(ids): Promise<void>;
    models: IKosModelContainer<T>;
    data: T[];
}

Type Parameters

  • T extends IKosDataModel = IKosDataModel

    The type of models contained in the container

Methods

  • Retrieves a model from the container by its ID.

    Parameters

    • id: string

      The unique identifier of the model to retrieve

    Returns undefined | T

    The model instance if found, undefined otherwise

  • Adds a model to the container.

    Parameters

    • model: T

      The model instance to add

    Returns void

  • Removes a model from the container by its ID.

    Parameters

    • id: string

      The unique identifier of the model to remove

    Returns void

  • Adds multiple models to the container at once.

    Parameters

    • models: T[]

      Array of model instances to add

    Returns void

  • Removes multiple models from the container by their IDs.

    Parameters

    • ids: string[]

      Array of unique identifiers of the models to remove

    Returns void

  • Removes a model from the container and destroys it. Convenience method that combines removeModel() and destroyKosModel().

    Parameters

    • id: string

      The unique identifier of the model to remove and destroy

    Returns Promise<void>

  • Removes multiple models from the container and destroys them. Convenience method that combines removeAll() and destroyKosModel().

    Parameters

    • ids: string[]

      Array of unique identifiers of the models to remove and destroy

    Returns Promise<void>

Properties

models: IKosModelContainer<T>

The container instance managing the models. Readonly property that provides access to the KosModelContainer. Compatible with IKosModelHolder interface. Updates automatically when models are added or removed.

data: T[]

Reactive array of all model instances in the container. This is the actual array of models, compatible with IKosModelHolder interface. Updates automatically when models are added or removed.