(abstract) OO.SortedEmitterList(sortingCallback)

Show:

(abstract) new SortedEmitterList(sortingCallback)

Manage a sorted list of OO.EmitterList objects.

Manage a sorted list of OO.EmitterList objects.

The sort order is based on a callback that compares two items. The return value of callback( a, b ) must be less than zero if a < b, greater than zero if a > b, and zero if a is equal to b. The callback should only return zero if the two objects are considered equal.

When an item changes in a way that could affect their sorting behavior, it must emit the itemSortChange event. This will cause it to be re-sorted automatically.

This mixin must be used in a class that also mixes in OO.EventEmitter.

Parameters:
Name Type Description
sortingCallback function

Callback that compares two items.

Mixes In:
Source:

Methods

addItems(items) → {OO.SortedEmitterList}

Add items to the sorted list.

Add items to the sorted list.

Parameters:
Name Type Description
items OO.EventEmitter | Array.<OO.EventEmitter>

Item to add or an array of items to add

Source:
Returns:
Type
OO.SortedEmitterList

findInsertionIndex(item) → {number}

Find the index a given item should be inserted at.

Find the index a given item should be inserted at. If the item is already in the list, this will return the index where the item currently is.

Parameters:
Name Type Description
item OO.EventEmitter

Items to insert

Source:
Returns:

The index the item should be inserted at

Type
number

onItemSortChange(item)

Handle a case where an item changed a property that relates to its sorted order.

Handle a case where an item changed a property that relates to its sorted order.

Parameters:
Name Type Description
item OO.EventEmitter

Item in the list

Source:

setSortingCallback(sortingCallback)

Change the sorting callback for this sorted list.

Change the sorting callback for this sorted list.

The callback receives two items. The return value of callback(a, b) must be less than zero if a < b, greater than zero if a > b, and zero if a is equal to b.

Parameters:
Name Type Description
sortingCallback function

Sorting callback

Source: