Class: AbstractSubscribableMap<K, V>
An abstract implementation of a subscribable set which allows adding, removing, and notifying subscribers.
Type parameters
Name |
---|
K |
V |
Hierarchy
AbstractSubscribableMap
Implements
SubscribableMap
<K
,V
>Subscribable
<ReadonlyMap
<K
,V
>>
Constructors
constructor
• new AbstractSubscribableMap<K
, V
>(): AbstractSubscribableMap
<K
, V
>
Type parameters
Name |
---|
K |
V |
Returns
AbstractSubscribableMap
<K
, V
>
Properties
initialNotifyFunc
• Protected
Readonly
initialNotifyFunc: (sub
: HandlerSubscription
<SubscribableMapHandler
<K
, V
>>) => 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 <SubscribableMapHandler <K , V >> |
Returns
void
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:28
isSubscribable
• Readonly
isSubscribable: true
Flags this object as a Subscribable.
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:14
isSubscribableMap
• Readonly
isSubscribableMap: true
Flags this object as a SubscribableMap.
Implementation of
SubscribableMap.isSubscribableMap
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:15
notifyDepth
• Protected
notifyDepth: number
= 0
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:25
onSubDestroyedFunc
• Protected
Readonly
onSubDestroyedFunc: (sub
: HandlerSubscription
<SubscribableMapHandler
<K
, V
>>) => 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 <SubscribableMapHandler <K , V >> |
Returns
void
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:31
singletonSub
• Protected
Optional
singletonSub: HandlerSubscription
<SubscribableMapHandler
<K
, V
>>
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:22
subs
• Protected
Optional
subs: HandlerSubscription
<SubscribableMapHandler
<K
, V
>>[]
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:24
Accessors
size
• get
size(): number
The number of elements contained in this map.
Returns
number
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:18
Methods
addSubscription
▸ addSubscription(sub
): void
Adds a subscription to this map.
Parameters
Name | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableMapHandler <K , V >> | The subscription to add. |
Returns
void
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:37
get
▸ get(): ReadonlyMap
<K
, V
>
Gets a read-only version of this map.
Returns
ReadonlyMap
<K
, V
>
A read-only version of this map.
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:49
getValue
▸ getValue(key
): undefined
| V
Gets the value stored under a given key in this map.
Parameters
Name | Type | Description |
---|---|---|
key | K | The key under which the value to get is stored. |
Returns
undefined
| V
The value stored under the specified key in this map, or undefined
if this map does not contain the
specified key.
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:57
has
▸ has(key
): boolean
Checks whether this map contains a key.
Parameters
Name | Type | Description |
---|---|---|
key | K | The key to check. |
Returns
boolean
Whether this map contains the specified key.
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:52
initialNotify
▸ initialNotify(sub
): void
Notifies a subscription of this map's current state.
Parameters
Name | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableMapHandler <K , V >> | The subscription to notify. |
Returns
void
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:173
map
▸ map<M
>(fn
, equalityFunc?
): MappedSubject
<[ReadonlyMap
<K
, V
>], M
>
Maps this subscribable to a new subscribable.
Type parameters
Name |
---|
M |
Parameters
Name | Type | Description |
---|---|---|
fn | (input : ReadonlyMap <K , V >, previousVal? : M ) => M | The function to use to map to the new subscribable. |
equalityFunc? | (a : M , b : M ) => boolean | The function to use to check for equality between mapped values. Defaults to the strict equality comparison (=== ). |
Returns
MappedSubject
<[ReadonlyMap
<K
, V
>], M
>
The mapped subscribable.
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:206
▸ map<M
>(fn
, equalityFunc
, mutateFunc
, initialVal
): MappedSubject
<[ReadonlyMap
<K
, V
>], M
>
Maps this subscribable to a new subscribable with a persistent, cached value which is mutated when it changes.
Type parameters
Name |
---|
M |
Parameters
Name | Type | Description |
---|---|---|
fn | (input : ReadonlyMap <K , V >, previousVal? : M ) => M | The function to use to map to the new subscribable. |
equalityFunc | (a : M , b : M ) => boolean | The function to use to check for equality between mapped values. |
mutateFunc | (oldVal : M , newVal : M ) => void | The function to use to change the value of the mapped subscribable. |
initialVal | M | The initial value of the mapped subscribable. |
Returns
MappedSubject
<[ReadonlyMap
<K
, V
>], M
>
The mapped subscribable.
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:215
notify
▸ notify(type
, key
, value
): void
Notifies subscriptions of a change in this map.
Parameters
Name | Type | Description |
---|---|---|
type | SubscribableMapEventType | The type of change. |
key | K | The key related to the change. |
value | V | The value related to the change. |
Returns
void
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:95
onSubDestroyed
▸ onSubDestroyed(sub
): void
Responds to when a subscription to this map is destroyed.
Parameters
Name | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableMapHandler <K , V >> | The destroyed subscription. |
Returns
void
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:184
pipe
▸ pipe(to
, paused?
): Subscription
Subscribes to and pipes this subscribable's state to a mutable subscribable. Whenever an update of this subscribable's state is received through the subscription, it will be used as an input to change the other subscribable's state.
Parameters
Name | Type | Description |
---|---|---|
to | MutableSubscribable <any , ReadonlyMap <K , V >> | The mutable subscribable to which to pipe this subscribable's state. |
paused? | boolean | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:243
▸ pipe<M
>(to
, map
, paused?
): Subscription
Subscribes to and pipes mapped inputs from another subscribable. Whenever an update of the other subscribable's state is received through the subscription, it will be transformed by the specified mapping function, and the transformed state will be used as an input to change this subscribable's state.
Type parameters
Name |
---|
M |
Parameters
Name | Type | Description |
---|---|---|
to | MutableSubscribable <any , M > | The mutable subscribable to which to pipe this subscribable's mapped state. |
map | (fromVal : ReadonlyMap <K , V >, toVal : M ) => M | The function to use to transform inputs. |
paused? | boolean | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:253
▸ pipe(to
, paused?
): Subscription
Subscribes to and pipes this map's state to a mutable subscribable map. Whenever a key-value pair added, changed, or removed event is received through the subscription, the same key-value pair will be added to, changed, or removed from the other map.
Parameters
Name | Type | Description |
---|---|---|
to | MutableSubscribableMap <K , V > | The mutable subscribable map to which to pipe this map's state. |
paused? | boolean | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.
Implementation of
SubscribableMap.pipe
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:262
sub
▸ sub(handler
, initialNotify?
, paused?
): Subscription
Subscribes to changes in this map's state.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
handler | SubscribableMapHandler <K , V > | undefined | A function which is called when this map's state changes. |
initialNotify | boolean | false | Whether to immediately invoke the callback function with this map'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
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:62
unsub
▸ unsub(handler
): void
Unsubscribes a callback function from this subscribable.
Parameters
Name | Type | Description |
---|---|---|
handler | SubscribableMapHandler <K , V > | 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.
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableMap.ts:77