Constructor for the Collection class. Initializes a new instance of Collection with the given entities and optional debounce value and prevData function.
The initial entities for the Collection. It can be an array of entities, a function that returns an array of entities, an array of Entity objects, or an instance of Collection.
Optional
_debounce: number = CHANGE_DEBOUNCEOptional debounce value for entity changes.
Optional
_prevData: (() => Entity<T>[]) = ...Optional function that returns the previous data of the Collection items.
Protected
_debounceOptional debounce value for entity changes.
Protected
_prevOptional function that returns the previous data of the Collection items.
Check if the object has any listeners attached to it.
True if the object has listeners, false otherwise.
Returns an array of all the IDs stored in the object.
An array containing all the IDs stored in the object.
Checks if the collection is empty.
Returns the last index of the items in the object.
The last index of the items.
Emits the given event with the specified arguments.
The name of the event to emit.
Rest
...args: any[]The arguments to pass to the event listeners.
Finds an entity in the list of items based on the given predicate.
The predicate function used to determine if an entity matches the condition. The predicate should accept two parameters: value and idx, representing the current entity and its index respectively. It should return a boolean value indicating whether the entity matches the condition.
Attaches a change handler to the given collection.
The function to be called when a change occurs in the collection. It should accept two parameters: - collection: The collection that has changed. - target: The entity that has been modified, or null if the entire collection has changed.
Subscribes a callback function to the given event name. The callback function will be triggered only once when the event is emitted.
The name of the event to subscribe to.
The callback function to be executed when the event is emitted.
Sets the data for the software and performs necessary operations.
The array of items to set as data.
Description
MVVM Array wrapper. Emmits
change
after push/pop/change of element