new GOWN.ListCollection(data)
Used to handle data manipulation (emit events when data changes, so for
example a List showing it can be updated and the user does not need to
call a special update function every time he adds/removes data from the
ListCollection.
Use the ListCollection functions to manipulate the data-array OR modify it
using the default array-functions and dispatch the CHANGED-Event yourself.
Name | Type | Description |
---|---|---|
data |
Array | optional The data source |
Extends
- EventEmitter
Members
-
static,readonlyGOWN.ListCollection.ADD_ITEMString
-
Dispatched when an item gets added to the list.
-
static,readonlyGOWN.ListCollection.CHANGEDString
-
Dispatched when the list data gets changed.
-
static,readonlyGOWN.ListCollection.REMOVE_ITEMString
-
Dispatched when a list item gets removed from the list.
-
static,readonlyGOWN.ListCollection.REPLACE_ITEMString
-
Dispatched when a list item gets replaced.
-
static,readonlyGOWN.ListCollection.RESETString
-
Dispatched when the list gets cleared.
-
dataArray
-
The data source for this collection. Has to be an array.
-
readonlylengthNumber
-
The length of the list
Methods
-
addItemAt(item, index)
-
Add a new item between index and index+1
Name Type Description item
Object The new item index
Number The index where the item gets inserted -
contains(item){boolean}
-
Checks if an item is in the list
Name Type Description item
Object The item to check Returns:
Type Description boolean True if the item is in the list, otherwise false -
getItemAt(index){Object}
-
Get an item at a specific index
Name Type Description index
Number The index to get the item from Returns:
Type Description Object The item at the specific index -
getItemIndex(item){Number}
-
Get the index of a list item
Name Type Description item
Object The list item Returns:
Type Description Number The item index -
pop()
-
Pop the last item from the last
-
push(item)
-
Push an item on the list at the last position
Name Type Description item
Object The item to push -
removeAll(item)
-
Removes all items from the list
Name Type Description item
-
removeItem(item)
-
Removes an item from the list
Name Type Description item
Object The item to remove -
removeItemAt(index){Object}
-
Removes the item at the specific index from the collection and returns it.
Name Type Description index
Number The item index Returns:
Type Description Object -
setItemAt(item, index)
-
Set an item at a specific index
Name Type Description item
Object The item that gets added index
Number The index where the item gets set -
shift()
-
Remove the item at the front of the list
-
unshift(item)
-
Add an item to the front of the list
Name Type Description item
Object The item to add