Skip to main content

Class: SortedMappedSubscribableArray<T>

A subscribable which provides a sorted version of a source SubscribableArray.

Type parameters

Name
T

Hierarchy

Properties

initialNotifyFunc

Protected Readonly initialNotifyFunc: (sub: HandlerSubscription<SubscribableArrayHandler<T>>) => void

A function which sends initial notifications to subscriptions.

Type declaration

▸ (sub): void

A function which sends initial notifications to subscriptions.

Parameters
NameType
subHandlerSubscription<SubscribableArrayHandler<T>>
Returns

void

Inherited from

AbstractSubscribableArray.initialNotifyFunc

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:20


notifyDepth

Protected notifyDepth: number = 0

Inherited from

AbstractSubscribableArray.notifyDepth

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:17


onSubDestroyedFunc

Protected Readonly onSubDestroyedFunc: (sub: HandlerSubscription<SubscribableArrayHandler<T>>) => void

A function which responds to when a subscription to this subscribable is destroyed.

Type declaration

▸ (sub): void

A function which responds to when a subscription to this subscribable is destroyed.

Parameters
NameType
subHandlerSubscription<SubscribableArrayHandler<T>>
Returns

void

Inherited from

AbstractSubscribableArray.onSubDestroyedFunc

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:23


singletonSub

Protected Optional singletonSub: HandlerSubscription<SubscribableArrayHandler<T>>

Inherited from

AbstractSubscribableArray.singletonSub

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:14


subs

Protected Optional subs: HandlerSubscription<SubscribableArrayHandler<T>>[]

Inherited from

AbstractSubscribableArray.subs

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:16

Accessors

length

get length(): number

The length of this array.

Returns

number

Overrides

AbstractSubscribableArray.length

Defined in

src/sdk/utils/datastructures/SortedMappedSubscribableArray.ts:14

Methods

addSubscription

addSubscription(sub): void

Adds a subscription to this array.

Parameters

NameTypeDescription
subHandlerSubscription<SubscribableArrayHandler<T>>The subscription to add.

Returns

void

Inherited from

AbstractSubscribableArray.addSubscription

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:29


destroy

destroy(): void

Destroys this subscribable. After destruction, this subscribable will no longer update in response to changes made to its source.

Returns

void

Defined in

src/sdk/utils/datastructures/SortedMappedSubscribableArray.ts:136


get

get(index): T

Gets an item from the array.

Parameters

NameTypeDescription
indexnumberThex index of the item to get.

Returns

T

An item.

Throws

Inherited from

AbstractSubscribableArray.get

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:77


getArray

getArray(): readonly T[]

Gets a read-only version of this array.

Returns

readonly T[]

a read-only version of this array.

Overrides

AbstractSubscribableArray.getArray

Defined in

src/sdk/utils/datastructures/SortedMappedSubscribableArray.ts:128


initialNotify

initialNotify(sub): void

Notifies a subscription of this array's current state.

Parameters

NameTypeDescription
subHandlerSubscription<SubscribableArrayHandler<T>>The subscription to notify.

Returns

void

Inherited from

AbstractSubscribableArray.initialNotify

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:176


notify

notify(index, type, modifiedItem?): void

Notifies subscriptions of a change in the array.

Parameters

NameTypeDescription
indexnumberThe index that was changed.
typeSubscribableArrayEventTypeThe type of subject event.
modifiedItem?T | readonly T[]The item modified by the operation.

Returns

void

Inherited from

AbstractSubscribableArray.notify

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:100


onSubDestroyed

onSubDestroyed(sub): void

Responds to when a subscription to this array is destroyed.

Parameters

NameTypeDescription
subHandlerSubscription<SubscribableArrayHandler<T>>The destroyed subscription.

Returns

void

Inherited from

AbstractSubscribableArray.onSubDestroyed

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:185


sub

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

Subscribes to changes in this array's state.

Parameters

NameTypeDefault valueDescription
handlerSubscribableArrayHandler<T>undefinedA function which is called when this array's state changes.
initialNotifybooleanfalseWhether 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.
pausedbooleanfalseWhether the new subscription should be initialized as paused. Defaults to false.

Returns

Subscription

The new subscription.

Inherited from

AbstractSubscribableArray.sub

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:41


tryGet

tryGet(index): undefined | T

Tries to get the value from the array.

Parameters

NameTypeDescription
indexnumberThe index of the item to get.

Returns

undefined | T

The value or undefined if not found.

Inherited from

AbstractSubscribableArray.tryGet

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:90


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.

Inherited from

AbstractSubscribableArray.unsub

Defined in

src/sdk/sub/AbstractSubscribableArray.ts:56


create

create<CT>(source, comparatorFunc, equalityFunc?): SortedMappedSubscribableArray<CT>

Creates a new SortedMappedSubscribableArray.

Type parameters

Name
CT

Parameters

NameTypeDescription
sourceSubscribableArray<CT>The source array subject for the new mapped sorted array.
comparatorFunc(a: CT, b: CT) => numberA function which defines the relative sorting priority of two elements. The function should return 0 if its arguments are to be sorted identically, a negative number if the first argument is to be sorted before the second argument, and a positive number if the first argument is to be sorted after the second argument.
equalityFunc?(a: CT, b: CT) => booleanA function which checks if two elements are equal. Defaults to the strict equality comparison (===) if not defined.

Returns

SortedMappedSubscribableArray<CT>

A new SortedMappedSubscribableArray.

Defined in

src/sdk/utils/datastructures/SortedMappedSubscribableArray.ts:47