Abstract Class: AbstractSubscribableArray<T>
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:10
An array-like class to observe changes in a list of objects. ArraySubject
Extended by
AbstractNearestSubscription
AdaptiveNearestSubscription
ArraySubject
SortedMappedSubscribableArray
FilteredMappedSubscribableArray
Type Parameters
Type Parameter | Description |
---|---|
T |
Implements
Constructors
Constructor
new AbstractSubscribableArray<
T
>():AbstractSubscribableArray
<T
>
Returns
AbstractSubscribableArray
<T
>
Properties
initialNotifyFunc()
protected
readonly
initialNotifyFunc: (sub
) =>void
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:20
A function which sends initial notifications to subscriptions.
Notifies a subscription of this array's current state.
Parameters
Parameter | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableArrayHandler <T >> | The subscription to notify. |
Returns
void
length
abstract
readonly
length:number
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:12
The length of this array.
Implementation of
notifyDepth
protected
notifyDepth:number
=0
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:17
onSubDestroyedFunc()
protected
readonly
onSubDestroyedFunc: (sub
) =>void
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:23
A function which responds to when a subscription to this subscribable is destroyed.
Responds to when a subscription to this array is destroyed.
Parameters
Parameter | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableArrayHandler <T >> | The destroyed subscription. |
Returns
void
singletonSub?
protected
optional
singletonSub:HandlerSubscription
<SubscribableArrayHandler
<T
>>
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:14
subs?
protected
optional
subs:HandlerSubscription
<SubscribableArrayHandler
<T
>>[]
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:16
Methods
addSubscription()
protected
addSubscription(sub
):void
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:29
Adds a subscription to this array.
Parameters
Parameter | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableArrayHandler <T >> | The subscription to add. |
Returns
void
get()
get(
index
):T
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:77
Gets an item from the array.
Parameters
Parameter | Type | Description |
---|---|---|
index | number | Thex index of the item to get. |
Returns
T
An item.
Throws
Implementation of
getArray()
abstract
getArray(): readonlyT
[]
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:69
Gets a read-only version of this array.
Returns
readonly T
[]
a read-only version of this array.
Implementation of
initialNotify()
protected
initialNotify(sub
):void
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:176
Notifies a subscription of this array's current state.
Parameters
Parameter | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableArrayHandler <T >> | The subscription to notify. |
Returns
void
notify()
protected
notify(index
,type
,modifiedItem?
):void
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:100
Notifies subscriptions of a change in the array.
Parameters
Parameter | Type | Description |
---|---|---|
index | number | The index that was changed. |
type | SubscribableArrayEventType | The type of subject event. |
modifiedItem? | T | readonly T [] | The item modified by the operation. |
Returns
void
onSubDestroyed()
protected
onSubDestroyed(sub
):void
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:185
Responds to when a subscription to this array is destroyed.
Parameters
Parameter | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableArrayHandler <T >> | The destroyed subscription. |
Returns
void
sub()
sub(
handler
,initialNotify
,paused
):Subscription
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:41
Subscribes to changes in this array's state.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
handler | SubscribableArrayHandler <T > | undefined | A function which is called when this array's state changes. |
initialNotify | boolean | false | Whether 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 | boolean | false | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.
Implementation of
tryGet()
tryGet(
index
):undefined
|T
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:90
Tries to get the value from the array.
Parameters
Parameter | Type | Description |
---|---|---|
index | number | The index of the item to get. |
Returns
undefined
| T
The value or undefined if not found.
Implementation of
unsub()
unsub(
handler
):void
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:56
Unsubscribes a callback function from this array.
Parameters
Parameter | Type | Description |
---|---|---|
handler | SubscribableArrayHandler <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.