Ember.TrackedArray Class packages/ember-runtime/lib/system/tracked_array.js:7


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.

Show:

_findArrayOperation

(index) private

Return an ArrayOperationMatch for the operation that contains the item at index.

Parameters:

index Number
the 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
newItems

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

removeItems

(index, count)

Track that count items were removed at index.

Parameters:

index
count
Show:

{array} items The items of the operation, if included. RETAIN and INSERT include their items, DELETE does not.

String private

Internal data structure to represent an array operation.

{number} rangeStart The 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` and `operation.count`.

ArrayOperation private

Internal data structure used to include information when looking up operations by item index.