Skip to main content

Class: DynamicList<DataType>

A list that handles dynamically adding and removing list items from an HTML element.

Type parameters

NameType
DataTypeextends DynamicListData

Constructors

constructor

new DynamicList<DataType>(data, itemsContainer, renderItem, sortItems?): DynamicList<DataType>

Creates a new instance of DynamicList.

Type parameters

NameType
DataTypeextends DynamicListData

Parameters

NameTypeDescription
dataSubscribableArray<DataType>An array of data items to display in this list.
itemsContainerElementThe Element to which this list's items will be rendered as children.
renderItem(data: DataType, index: number) => VNodeA function that used to render this list's items. The function is called for every list item that is added to this list. If the root node returned by the function is a DisplayComponent, then its destroy() method will be called when the item is removed from this list.
sortItems?(a: DataType, b: DataType) => numberA function to sort data items before rendering them. The function should return a negative number if the first item should be rendered before the second, a positive number if the first item should be rendered after the second, or zero if the two items' relative order does not matter. If not defined, items will be rendered in the order in which they appear in the data item array.

Returns

DynamicList<DataType>

Defined in

src/garminsdk/components/list/DynamicList.ts:46

Properties

visibleItemCount

Readonly visibleItemCount: Subscribable<number>

The number of visible items in this list.

Defined in

src/garminsdk/components/list/DynamicList.ts:16

Methods

destroy

destroy(): void

Destroys this list.

Returns

void

Defined in

src/garminsdk/components/list/DynamicList.ts:463


forEachComponent

forEachComponent<T>(fn, visibleOnly?, sortedOrder?): void

Iterates over each rendered component and executes a callback function.

Type parameters

NameType
Textends DisplayComponent<any, []>

Parameters

NameTypeDefault valueDescription
fn(component: undefined | T, index: number) => voidundefinedThe callback function to execute for each component. The function should take two arguments: the first argument is the iterated component, and the second argument is the index of the component in the iteration.
visibleOnlybooleanfalseWhether to only iterate over components whose associated data items have their visibility flags set to true. Defaults to false.
sortedOrderbooleanfalseWhether to iterate over components in sorted order instead of the order in which their associated data items appear in the data array. Defaults to false.

Returns

void

Defined in

src/garminsdk/components/list/DynamicList.ts:174


getRenderedItem

getRenderedItem(index): undefined | NodeInstance

Gets the rendered instance of a data item in this list.

Parameters

NameTypeDescription
indexnumberThe index of the data item for which to get the rendered instance.

Returns

undefined | NodeInstance

The rendered instance of the specified data item, or undefined if index is out of bounds.

Defined in

src/garminsdk/components/list/DynamicList.ts:161


indexOfSortedIndex

indexOfSortedIndex(sortedIndex): number

Gets the data item index of a sorted index.

Parameters

NameTypeDescription
sortedIndexnumberA sorted index.

Returns

number

The index of the data item that is sorted to the specified index, or -1 if the sorted index is out of bounds.

Defined in

src/garminsdk/components/list/DynamicList.ts:126


indexOfSortedVisibleIndex

indexOfSortedVisibleIndex(sortedVisibleIndex): number

Gets the data item index of a sorted index after hidden items have been excluded.

Parameters

NameTypeDescription
sortedVisibleIndexnumberA sorted index after hidden items have been excluded.

Returns

number

The index of the data item that is sorted to the specified index after hidden items have been excluded, or -1 if the sorted index is out of bounds.

Defined in

src/garminsdk/components/list/DynamicList.ts:136


sortedIndexOfData

sortedIndexOfData(data): number

Gets the sorted index of a data item.

Parameters

NameTypeDescription
dataDataTypeA data item.

Returns

number

The index to which the specified data item is sorted, or -1 if the item is not in this list.

Defined in

src/garminsdk/components/list/DynamicList.ts:77


sortedIndexOfIndex

sortedIndexOfIndex(index): number

Gets the sorted index of a data item index.

Parameters

NameTypeDescription
indexnumberA data item index.

Returns

number

The index to which the specified data item index is sorted, or -1 if the data index is out of bounds.

Defined in

src/garminsdk/components/list/DynamicList.ts:68


sortedVisibleIndexOfData

sortedVisibleIndexOfData(data): number

Gets the sorted index of a data item after hidden items have been excluded.

Parameters

NameTypeDescription
dataDataTypeA data item.

Returns

number

The index to which the specified data item is sorted after hidden items have been excluded, or -1 if the item is not in this list or is itself hidden.

Defined in

src/garminsdk/components/list/DynamicList.ts:113


sortedVisibleIndexOfIndex

sortedVisibleIndexOfIndex(index): number

Gets the sorted index of a data item index after hidden items have been excluded.

Parameters

NameTypeDescription
indexnumberA data item index.

Returns

number

The index to which the specified data item index is sorted after hidden items have been excluded, or -1 if the data index is out of bounds or the data item whose index was given is itself hidden.

Defined in

src/garminsdk/components/list/DynamicList.ts:87


updateOrder

updateOrder(): void

Updates the order of the rendered items in this list.

Returns

void

Defined in

src/garminsdk/components/list/DynamicList.ts:437