Class: ListModel

core.ListModel

Class representing a list model of arbitrary data items.

new core.ListModel ()

Properties:
Name Type Description
data Array.<any>

The data items of the model.

size number

[readonly] The current amount of items in the model.

Extends

Methods

at (n)any

Returns the data item at the given position.

Name Type Description
n number

The position.

Returns:
Type Description
any The data item at that position.

bulkInsert (at, bulk)

Inserts a bulk of data items at the given position.

Name Type Description
at number

The position to insert at.

bulk Array.<any>

The bulk of data items.

insert (at, data)

Inserts a data item at the given position.

Name Type Description
at number

The position to insert at.

data any

The data item.

insertOrdered (data, comparator)number

Inserts a data item at the position determined by a comparator function.

Name Type Description
data any

The data item.

comparator function

The comparator function.

Returns:
Type Description
number The insertion position.

remove (at)

Removes the data item at the given position.

Name Type Description
at number

The position to remove from.

replace (at, item)any

Replaces the data item at the given position and returns the previous item.

Name Type Description
at number

The position to replace at.

item any

The new item.

Returns:
Type Description
any The previous item.

reset (data)

Resets the model with the given data items.

Name Type Description
data Array.<any>

The new data items.

sequence (from, n)Array.<number>

Creates a sequence of numbers to be used for the data property.

Name Type Description
from number

The starting number.

n number

The amount of sequential numbers.

Returns:
Type Description
Array.<number> A sequence of numbers.

Events

core.ListModel.event:modelInsert

Is triggered when data items were inserted.

Name Type Description
at number

The position where the items where inserted at.

n number

The amount of items inserted.

core.ListModel.event:modelRemove

Is triggered when data items were removed.

Name Type Description
at number

The position where the item was removed from.

core.ListModel.event:modelReplace

Is triggered when a data item was changed.

Name Type Description
at number

The position of the item that was replaced.

core.ListModel.event:modelReset

Is triggered when the model was reset.