Constructor for the Collection class. Initializes a new instance of Collection with the given entities and optional debounce value and prevData function.
Optionalentities: Collection<T> | T[] | () => T[] | Entity<T>[]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: numberOptional debounce value for entity changes.
Optional_prevData: () => Entity<T>[]Optional function that returns the previous data of the Collection items.
Protected_debounceProtected_prevClear function that performs the following operations:
Emits the given event with the specified arguments.
The name of the event to emit.
The arguments to pass to the event listeners.
Filter method for an array of items.
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.
Finds an entity by its ID.
Calls a function for each element in the array and passes the value and index as arguments.
Retrieves the listeners associated with the given event key.
The event key to retrieve the listeners for.
An array of listeners associated with the given event key.
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.
Handles drop changes for all entities in the collection. Triggers the drop changes event after processing.
Applies a callback function to each value in the map and returns a new array of the results.
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.
Adds items to the collection and performs necessary operations.
Executes a refresh action triggering an event.
Removes an item from the collection by its ID.
Removes all items from the collection and performs necessary cleanup.
Removes an item from the collection by its id.
The id of the item to be removed.
Sets the data for the software and performs necessary operations.
Checks if at least one element in the array passes the provided test.
Subscribes a callback function to the specified event name.
The key of the event.
The callback function to be executed when the event is triggered.
Converts an array of objects to an array of plain objects using the "toObject" method of each object.
Removes a callback function from the list of event listeners for the specified event.
The key of the event to unsubscribe from.
The callback function to remove from the event listeners.
Clears all event handlers registered for the current object.
Upsert function for adding or updating items in a collection.
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.
Description
MVVM Array wrapper. Emmits
changeafter push/pop/change of element