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:
-
index
Numberthe 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:
-
index
Object -
newItems
Object
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:
-
callback
Function
ArrayOperation
-
type
-
count
-
items
Internal data structure to represent an array operation.
Parameters:
-
type
StringThe type of the operation. One of
Ember.TrackedArray.{RETAIN, INSERT, DELETE}
-
count
NumberThe number of items in this operation.
-
items
ArrayThe 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:
-
operation
ArrayOperation -
index
NumberThe index of
operation
in the array of operations. -
split
BooleanWhether or not the item index searched for would require a split for a new operation type.
-
rangeStart
NumberThe index of the first item in the operation, with respect to the tracked array. The index of the last item can be computed from
rangeStart
andoperation.count
.
removeItems
-
index
-
count
Track that count
items were removed at index
.
Parameters:
-
index
Object -
count
Object