Skip to main content

Interface: SubscribableArray<T>

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

Type parameters

Name
T

Hierarchy

Implemented by

Properties

length

Readonly length: number

The length of this array.

Defined in

src/sdk/sub/SubscribableArray.ts:27

Methods

get

get(index): T

Retrieves an element from this array.

Parameters

NameTypeDescription
indexnumberThe index of the element.

Returns

T

the element at the specified index.

Throws

Error if index is out of bounds.

Defined in

src/sdk/sub/SubscribableArray.ts:35


getArray

getArray(): readonly T[]

Gets a read-only version of this array.

Returns

readonly T[]

a read-only version of this array.

Defined in

src/sdk/sub/SubscribableArray.ts:48


sub

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

Subscribes to changes in this array's state.

Parameters

NameTypeDescription
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.

Defined in

src/sdk/sub/SubscribableArray.ts:58


tryGet

tryGet(index): undefined | T

Attempts to retrieve an element from this array.

Parameters

NameTypeDescription
indexnumberThe index of the element.

Returns

undefined | T

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

Defined in

src/sdk/sub/SubscribableArray.ts:42


unsub

unsub(handler): void

Unsubscribes a callback function from this array.

Parameters

NameTypeDescription
handlerSubscribableArrayHandler<T>The function to unsubscribe.

Returns

void

Deprecated

This method has been deprecated in favor of using the Subscription object returned by .sub() to manage subscriptions.

Defined in

src/sdk/sub/SubscribableArray.ts:66