Optional containerContainer property name on the model instance.
"container"
@kosContainerAware({ containerProperty: "devices" })
class DeviceContainer {
// Access via: this.devices.addModel(...)
}
Optional includeWhether to include convenience methods (getModel, addModel, removeModel, addAll, removeAll, removeAndDestroy, removeAndDestroyAll).
true
@kosContainerAware({ includeMethods: false })
class Container {
// Only this.container property available, no convenience methods
}
Optional includeWhether to include reactive getters (models, data).
true
@kosContainerAware({ includeGetters: false })
class Container {
// No this.models or this.data getters, use this.container.data directly
}
Optional containerContainer-specific configuration options passed to KosModelContainer constructor.
Optional sortDefault property to sort models by
Optional indexIndex mapping for efficient queries. Keys are index names, values are either:
indexMap: {
byStatus: "connectionStatus", // Property-based
byType: (device) => device.type.toLowerCase(), // Function-based
needsUpdate: (device) => device.version < "2.0" // Boolean logic
}
Optional parentParent model ID for the container. If not provided, automatically uses the modelId parameter from the model's constructor.
Inferred from constructor modelId parameter
Optional extensionExtension identifier for the container
Optional maxSAFETY NET: Maximum number of models this container can hold. When exceeded, models are automatically evicted and destroyed based on evictionStrategy.
Primary use case: Prevent memory overflow when cleanup handlers are missing or data becomes inconsistent. Set higher than normal usage to catch edge cases.
containerOptions: {
maxCapacity: 10000, // Safety net: expect ~100-1000 normally
evictionStrategy: 'fifo'
}
Optional evictionStrategy for selecting which models to evict when maxCapacity is exceeded.
'fifo'
Optional evictionNumber of models to evict when maxCapacity is exceeded.
Math.max(10, Math.ceil(maxCapacity * 0.1))
Optional customCustom filter function for 'custom' eviction strategy. Should return models that are candidates for eviction.
customEvictionFilter: (models) => {
return models.filter(m =>
m.status === 'resolved' &&
Date.now() - m.resolvedAt > 3600000
);
}
@kosContainerAware({
containerOptions: {
sortKey: "name",
indexMap: {
byType: "deviceType",
active: (device) => device.isOnline
},
parentId: "custom-parent", // Overrides automatic inference
extensionId: "device-manager",
maxCapacity: 1000, // Safety net for unbounded growth
evictionStrategy: "fifo"
}
})
Optional modelsCustom name for the reactive models array getter.
"models"
@kosContainerAware({ modelsProperty: "items" })
class Container {
get items() { return this.container.data; } // Instead of 'models'
}
Optional legacyLegacy compatibility mode. Uses '_models' as the container property name instead of 'container' for backward compatibility with existing code.
false
Use containerProperty instead for new code
Configuration options for the
Kos Container Aware
decorator.