Class: ArraySubject<T>
Defined in: src/sdk/sub/ArraySubject.ts:9
An array-like class to observe changes in a list of objects. ArraySubject
Extends
Type Parameters
Type Parameter | Description |
---|---|
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
Inherited from
AbstractSubscribableArray
.initialNotifyFunc
notifyDepth
protected
notifyDepth:number
=0
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:17
Inherited from
AbstractSubscribableArray
.notifyDepth
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
Inherited from
AbstractSubscribableArray
.onSubDestroyedFunc
singletonSub?
protected
optional
singletonSub:HandlerSubscription
<SubscribableArrayHandler
<T
>>
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:14
Inherited from
AbstractSubscribableArray
.singletonSub
subs?
protected
optional
subs:HandlerSubscription
<SubscribableArrayHandler
<T
>>[]
Defined in: src/sdk/sub/AbstractSubscribableArray.ts:16
Inherited from
AbstractSubscribableArray
.subs
Accessors
length
Get Signature
get length():
number
Defined in: src/sdk/sub/ArraySubject.ts:14
The length of this array.
Returns
number
The length of this array.
Overrides
AbstractSubscribableArray
.length
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
Inherited from
AbstractSubscribableArray
.addSubscription
clear()
clear():
void
Defined in: src/sdk/sub/ArraySubject.ts:101
Clears all data in the array.
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
Inherited from
getArray()
getArray(): readonly
T
[]
Defined in: src/sdk/sub/ArraySubject.ts:110
Gets the array.
Returns
readonly T
[]
The array.
Overrides
AbstractSubscribableArray
.getArray
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
Inherited from
AbstractSubscribableArray
.initialNotify
insert()
insert(
item
,index?
):void
Defined in: src/sdk/sub/ArraySubject.ts:44
Inserts a new item at the end or the specified index.
Parameters
Parameter | Type | Description |
---|---|---|
item | T | The item to insert. |
index? | number | The optional index to insert the item to. Will add the item at then end if index not given. |
Returns
void
insertRange()
insertRange(
index?
,arr?
):void
Defined in: src/sdk/sub/ArraySubject.ts:60
Inserts items of an array beginning at the specified index.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
index? | number | 0 | The index to begin inserting the array items. |
arr? | readonly T [] | undefined | The array to insert. |
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
Inherited from
AbstractSubscribableArray
.notify
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
Inherited from
AbstractSubscribableArray
.onSubDestroyed
removeAt()
removeAt(
index
):void
Defined in: src/sdk/sub/ArraySubject.ts:69
Removes the item at the specified index.
Parameters
Parameter | Type | Description |
---|---|---|
index | number | The index of the item to remove. |
Returns
void
removeItem()
removeItem(
item
):boolean
Defined in: src/sdk/sub/ArraySubject.ts:79
Removes the given item from the array.
Parameters
Parameter | Type | Description |
---|---|---|
item | T | The item to remove. |
Returns
boolean
Returns a boolean indicating if the item was found and removed.
set()
set(
arr
):void
Defined in: src/sdk/sub/ArraySubject.ts:93
Replaces all items in the array with the new array.
Parameters
Parameter | Type | Description |
---|---|---|
arr | readonly T [] | The array. |
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.
Inherited from
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.
Inherited from
AbstractSubscribableArray
.tryGet
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.
Inherited from
AbstractSubscribableArray
.unsub
create()
static
create<AT
>(arr
):ArraySubject
<AT
>
Defined in: src/sdk/sub/ArraySubject.ts:35
Creates and returns a new observable array.
Type Parameters
Type Parameter | Description |
---|---|
AT | The type of the array items. |
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
arr | AT [] | [] | The initial array elements. |
Returns
ArraySubject
<AT
>
A new instance of SubjectArray.