Array that sends notifications on changes.
The class raises the collectionChanged event when changes are made with the push, pop, splice, shift, unshift, insert, or remove methods.
Warning: Changes made by assigning values directly to array members or to the length of the array do not raise the collectionChanged event.
constructor(data?: T[]): ObservableArray
Initializes a new instance of the ObservableArray class.
Array containing items used to populate the ObservableArray.
Gets a value that indicates whether notifications are currently suspended (see beginUpdate and endUpdate).
beginUpdate(): void
Suspends notifications until the next call to endUpdate.
clear(): void
Removes all items from the array.
deferUpdate(fn: Function): void
Executes a function within a beginUpdate/endUpdate block.
The collection will not be refreshed until the function finishes. This method ensures endUpdate is called even if the function throws an exception.
Function to be executed without updates.
The index where the search should start.
insert(index: number, item: T): void
Inserts an item at a specific position in the array.
Position where the item will be added.
Item to add to the array.
onCollectionChanged(e?: NotifyCollectionChangedEventArgs): void
Raises the collectionChanged event.
Contains a description of the change.
push(...items: T[]): number
Adds one or more items to the end of the array.
One or more items to add to the array.
remove(item: T): boolean
Removes an item from the array.
Item to remove.
removeAt(index: number): void
Removes an item at a specific position in the array.
Position of the item to remove.
setAt(index: number, item: T): void
Assigns an item at a specific position in the array.
Position where the item will be assigned.
Item to assign to the array.
shift(): T
Removes the first element from the array and returns that element.
This method changes the length of the array.
slice(begin?: number, end?: number): T[]
Creates a shallow copy of a portion of an array.
Position where the copy starts.
Position where the copy ends.
sort(compareFn?: Function): this
Sorts the elements of the array in place.
Specifies a function that defines the sort order. If specified, the function should take two arguments and should return -1, +1, or 0 to indicate the first argument is smaller, greater than, or equal to the second argument. If omitted, the array is sorted in dictionary order according to the string conversion of each element.
splice(index: number, count: number, ...item: T[]): T[]
Removes and/or adds items to the array.
Position where items will be added or removed.
Number of items to remove from the array.
One or more items to add to the array.
unshift(...items: T[]): number
Adds one or more elements to the beginning of the array and returns the new length of the array.
One or more items to add to the array.