On September 25th, 2024, we released v2 of the Apps SDK. To learn what’s new and how to upgrade, see Migration FAQ and Migration guide.

ReadableList

API reference for the ReadableList type.
This version of the API is a preview. Preview APIs are unstable and may change without warning. You can't release public apps using this API until it's stable.

A list that cannot be changed.

Type Parameters

M

Methods

countfunction
Required

Gets the number of items in the list.

Returns

The number of items.

number

toArrayfunction
Required

Converts the list to an array.

Returns

An array containing all items. The items are the same as in the list.

readonly M[]

forEachfunction
Required

Executes a function for each item in the list.

Parameters

callbackForEachCallback<M>
Required

The function to run for each item.

Parameters

itemM
Required

The current item in the list.

indexnumber
Required

The index of the current item.

Returns

void

Returns

void

filterfunction
Required

Creates a new array with items that pass a test.

Parameters

filterFilterPredicate<M>
Required

A function that tests each item. Returns true to keep the item.

Parameters

itemM
Required

The item to test.

Returns

true if the item should be included, otherwise false.

boolean

Returns

An array of items that passed the test.

readonly M[]