Skip to main content

Interface: SubscribableArray<T>

Defined in: src/sdk/sub/SubscribableArray.ts:25

An array which allows others to subscribe to be notified of changes in its state.

Extended by​

Type Parameters​

Type Parameter
T

Properties​

length​

readonly length: number

Defined in: src/sdk/sub/SubscribableArray.ts:27

The length of this array.

Methods​

get()​

get(index): T

Defined in: src/sdk/sub/SubscribableArray.ts:35

Retrieves an element from this array.

Parameters​

ParameterTypeDescription
indexnumberThe index of the element.

Returns​

T

the element at the specified index.

Throws​

Error if index is out of bounds.


getArray()​

getArray(): readonly T[]

Defined in: src/sdk/sub/SubscribableArray.ts:48

Gets a read-only version of this array.

Returns​

readonly T[]

a read-only version of this array.


sub()​

sub(handler, initialNotify?, paused?): Subscription

Defined in: src/sdk/sub/SubscribableArray.ts:58

Subscribes to changes in this array's state.

Parameters​

ParameterTypeDescription
handlerSubscribableArrayHandler<T>A function which is called when this array's state changes.
initialNotify?booleanWhether to immediately invoke the callback function with this array's current state. Defaults to false. This argument is ignored if the subscription is initialized as paused.
paused?booleanWhether the new subscription should be initialized as paused. Defaults to false.

Returns​

Subscription

The new subscription.


tryGet()​

tryGet(index): T | undefined

Defined in: src/sdk/sub/SubscribableArray.ts:42

Attempts to retrieve an element from this array.

Parameters​

ParameterTypeDescription
indexnumberThe index of the element.

Returns​

T | undefined

the element at the specified index, or undefined if index is out of bounds.