Constructor
new OO.SortedEmitterList(sortingCallback)abstract
#
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:
OO.EmitterList
objects.
Methods
addItems(items) → {OO.SortedEmitterList}
#
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. 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.
Parameters:
Name | Type | Description |
---|---|---|
item |
OO.EventEmitter | Item in the list |
- Source:
Handle a case where an item changed a property that relates to its sorted order.
setSortingCallback(sortingCallback)
#
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:
Events
itemSortChange()private
#
An item has changed properties that affect its sort positioning inside the list.
- Source:
An item has changed properties that affect its sort positioning inside the list.