Class: ArraySubject<T>
An array-like class to observe changes in a list of objects. ArraySubject
Type parameters
Name |
---|
T |
Hierarchy
↳
ArraySubject
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
Name | Type |
---|---|
sub | HandlerSubscription <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
Name | Type |
---|---|
sub | HandlerSubscription <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/sub/ArraySubject.ts:14
Methods
addSubscription
▸ addSubscription(sub
): void
Adds a subscription to this array.
Parameters
Name | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableArrayHandler <T >> | The subscription to add. |
Returns
void
Inherited from
AbstractSubscribableArray.addSubscription
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:29
clear
▸ clear(): void
Clears all data in the array.
Returns
void
Defined in
src/sdk/sub/ArraySubject.ts:101
get
▸ get(index
): T
Gets an item from the array.
Parameters
Name | Type | Description |
---|---|---|
index | number | Thex index of the item to get. |
Returns
T
An item.
Throws
Inherited from
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:77
getArray
▸ getArray(): readonly T
[]
Gets the array.
Returns
readonly T
[]
The array.
Overrides
AbstractSubscribableArray.getArray
Defined in
src/sdk/sub/ArraySubject.ts:110
initialNotify
▸ initialNotify(sub
): void
Notifies a subscription of this array's current state.
Parameters
Name | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableArrayHandler <T >> | The subscription to notify. |
Returns
void
Inherited from
AbstractSubscribableArray.initialNotify
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:176
insert
▸ insert(item
, index?
): void
Inserts a new item at the end or the specified index.
Parameters
Name | 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
Defined in
src/sdk/sub/ArraySubject.ts:44
insertRange
▸ insertRange(index?
, arr
): void
Inserts items of an array beginning at the specified index.
Parameters
Name | 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
Defined in
src/sdk/sub/ArraySubject.ts:60
notify
▸ notify(index
, type
, modifiedItem?
): void
Notifies subscriptions of a change in the array.
Parameters
Name | 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
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:100
onSubDestroyed
▸ onSubDestroyed(sub
): void
Responds to when a subscription to this array is destroyed.
Parameters
Name | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableArrayHandler <T >> | The destroyed subscription. |
Returns
void
Inherited from
AbstractSubscribableArray.onSubDestroyed
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:185
removeAt
▸ removeAt(index
): void
Removes the item at the specified index.
Parameters
Name | Type | Description |
---|---|---|
index | number | The index of the item to remove. |
Returns
void
Defined in
src/sdk/sub/ArraySubject.ts:69
removeItem
▸ removeItem(item
): boolean
Removes the given item from the array.
Parameters
Name | Type | Description |
---|---|---|
item | T | The item to remove. |
Returns
boolean
Returns a boolean indicating if the item was found and removed.
Defined in
src/sdk/sub/ArraySubject.ts:79
set
▸ set(arr
): void
Replaces all items in the array with the new array.
Parameters
Name | Type | Description |
---|---|---|
arr | readonly T [] | The array. |
Returns
void
Defined in
src/sdk/sub/ArraySubject.ts:93
sub
▸ sub(handler
, initialNotify?
, paused?
): Subscription
Subscribes to changes in this array's state.
Parameters
Name | 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
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:41
tryGet
▸ tryGet(index
): undefined
| T
Tries to get the value from the array.
Parameters
Name | 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
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:90
unsub
▸ unsub(handler
): void
Unsubscribes a callback function from this array.
Parameters
Name | 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
Defined in
src/sdk/sub/AbstractSubscribableArray.ts:56
create
▸ create<AT
>(arr?
): ArraySubject
<AT
>
Creates and returns a new observable array.
Type parameters
Name | Description |
---|---|
AT | The type of the array items. |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
arr | AT [] | [] | The initial array elements. |
Returns
ArraySubject
<AT
>
A new instance of SubjectArray.
Static
Defined in
src/sdk/sub/ArraySubject.ts:35