Ember.TrackedArray Class
An Ember.TrackedArray tracks array operations. It's useful when you want to
lazily compute the indexes of items in an array after they've been shifted by
subsequent operations.
Item Index
Methods
_findArrayOperation
-
index
Return an ArrayOperationMatch for the operation that contains the item at index.
Parameters:
-
indexNumberthe index of the item whose operation information should be returned.
addItems
-
index -
newItems
Track that newItems were added to the tracked array at index.
Parameters:
-
indexObject -
newItemsObject
apply
-
callback
Apply all operations, reducing them to retain:n, for n, the number of
items in the array.
callback will be called for each operation and will be passed the following arguments:
- {array} items The items for the given operation
- {number} offset The computed offset of the items, ie the index in the array of the first item for this operation.
- {string} operation The type of the operation. One of
Ember.TrackedArray.{RETAIN, DELETE, INSERT}
Parameters:
-
callbackFunction
ArrayOperation
-
type -
count -
items
Internal data structure to represent an array operation.
Parameters:
-
typeStringThe type of the operation. One of
Ember.TrackedArray.{RETAIN, INSERT, DELETE} -
countNumberThe number of items in this operation.
-
itemsArrayThe items of the operation, if included. RETAIN and INSERT include their items, DELETE does not.
ArrayOperationMatch
-
operation -
index -
split -
rangeStart
Internal data structure used to include information when looking up operations by item index.
Parameters:
-
operationArrayOperation -
indexNumberThe index of
operationin the array of operations. -
splitBooleanWhether or not the item index searched for would require a split for a new operation type.
-
rangeStartNumberThe index of the first item in the operation, with respect to the tracked array. The index of the last item can be computed from
rangeStartandoperation.count.
removeItems
-
index -
count
Track that count items were removed at index.
Parameters:
-
indexObject -
countObject
