Skip to main content

Class: MapSubject<K, V>

A subscribable map whose key-value pairs can be freely added and removed.

Type parameters

Name
K
V

Hierarchy

Implements

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
NameType
subHandlerSubscription<SubscribableMapHandler<K, V>>
Returns

void

Inherited from

AbstractSubscribableMap.initialNotifyFunc

Defined in

src/sdk/sub/AbstractSubscribableMap.ts:28


isMutableSubscribable

Readonly isMutableSubscribable: true

Flags this object as a MutableSubscribable.

Implementation of

MutableSubscribable.isMutableSubscribable

Defined in

src/sdk/sub/MapSubject.ts:9


isMutableSubscribableMap

Readonly isMutableSubscribableMap: true

Flags this object as a MutableSubscribableMap.

Implementation of

MutableSubscribableMap.isMutableSubscribableMap

Defined in

src/sdk/sub/MapSubject.ts:10


isSubscribable

Readonly isSubscribable: true

Flags this object as a Subscribable.

Implementation of

MutableSubscribable.isSubscribable

Inherited from

AbstractSubscribableMap.isSubscribable

Defined in

src/sdk/sub/AbstractSubscribableMap.ts:14


isSubscribableMap

Readonly isSubscribableMap: true

Flags this object as a SubscribableMap.

Implementation of

MutableSubscribableMap.isSubscribableMap

Inherited from

AbstractSubscribableMap.isSubscribableMap

Defined in

src/sdk/sub/AbstractSubscribableMap.ts:15


notifyDepth

Protected notifyDepth: number = 0

Inherited from

AbstractSubscribableMap.notifyDepth

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
NameType
subHandlerSubscription<SubscribableMapHandler<K, V>>
Returns

void

Inherited from

AbstractSubscribableMap.onSubDestroyedFunc

Defined in

src/sdk/sub/AbstractSubscribableMap.ts:31


singletonSub

Protected Optional singletonSub: HandlerSubscription<SubscribableMapHandler<K, V>>

Inherited from

AbstractSubscribableMap.singletonSub

Defined in

src/sdk/sub/AbstractSubscribableMap.ts:22


subs

Protected Optional subs: HandlerSubscription<SubscribableMapHandler<K, V>>[]

Inherited from

AbstractSubscribableMap.subs

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

MutableSubscribableMap.size

Inherited from

AbstractSubscribableMap.size

Defined in

src/sdk/sub/AbstractSubscribableMap.ts:18

Methods

addSubscription

addSubscription(sub): void

Adds a subscription to this map.

Parameters

NameTypeDescription
subHandlerSubscription<SubscribableMapHandler<K, V>>The subscription to add.

Returns

void

Inherited from

AbstractSubscribableMap.addSubscription

Defined in

src/sdk/sub/AbstractSubscribableMap.ts:37


clear

clear(): void

Removes all key-value pairs from this map.

Returns

void

Implementation of

MutableSubscribableMap.clear

Defined in

src/sdk/sub/MapSubject.ts:85


delete

delete(key): boolean

Removes a key-value pair from this map.

Parameters

NameTypeDescription
keyKThe key to remove.

Returns

boolean

Whether the key-value pair was removed.

Implementation of

MutableSubscribableMap.delete

Defined in

src/sdk/sub/MapSubject.ts:73


get

get(): ReadonlyMap<K, V>

Gets this item's state.

Returns

ReadonlyMap<K, V>

This item's state.

Implementation of

MutableSubscribableMap.get

Overrides

AbstractSubscribableMap.get

Defined in

src/sdk/sub/MapSubject.ts:36


getValue

getValue(key): undefined | V

Gets the value stored under a given key in this map.

Parameters

NameTypeDescription
keyKThe 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

MutableSubscribableMap.getValue

Inherited from

AbstractSubscribableMap.getValue

Defined in

src/sdk/sub/AbstractSubscribableMap.ts:57


has

has(key): boolean

Checks whether this map contains a key.

Parameters

NameTypeDescription
keyKThe key to check.

Returns

boolean

Whether this map contains the specified key.

Implementation of

MutableSubscribableMap.has

Inherited from

AbstractSubscribableMap.has

Defined in

src/sdk/sub/AbstractSubscribableMap.ts:52


initialNotify

initialNotify(sub): void

Notifies a subscription of this map's current state.

Parameters

NameTypeDescription
subHandlerSubscription<SubscribableMapHandler<K, V>>The subscription to notify.

Returns

void

Inherited from

AbstractSubscribableMap.initialNotify

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

NameTypeDescription
fn(input: ReadonlyMap<K, V>, previousVal?: M) => MThe function to use to map to the new subscribable.
equalityFunc?(a: M, b: M) => booleanThe 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

MutableSubscribable.map

Inherited from

AbstractSubscribableMap.map

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

NameTypeDescription
fn(input: ReadonlyMap<K, V>, previousVal?: M) => MThe function to use to map to the new subscribable.
equalityFunc(a: M, b: M) => booleanThe function to use to check for equality between mapped values.
mutateFunc(oldVal: M, newVal: M) => voidThe function to use to change the value of the mapped subscribable.
initialValMThe initial value of the mapped subscribable.

Returns

MappedSubject<[ReadonlyMap<K, V>], M>

The mapped subscribable.

Implementation of

MutableSubscribable.map

Inherited from

AbstractSubscribableMap.map

Defined in

src/sdk/sub/AbstractSubscribableMap.ts:215


notify

notify(type, key, value): void

Notifies subscriptions of a change in this map.

Parameters

NameTypeDescription
typeSubscribableMapEventTypeThe type of change.
keyKThe key related to the change.
valueVThe value related to the change.

Returns

void

Inherited from

AbstractSubscribableMap.notify

Defined in

src/sdk/sub/AbstractSubscribableMap.ts:95


onSubDestroyed

onSubDestroyed(sub): void

Responds to when a subscription to this map is destroyed.

Parameters

NameTypeDescription
subHandlerSubscription<SubscribableMapHandler<K, V>>The destroyed subscription.

Returns

void

Inherited from

AbstractSubscribableMap.onSubDestroyed

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

NameTypeDescription
toMutableSubscribable<any, ReadonlyMap<K, V>>The mutable subscribable to which to pipe this subscribable's state.
paused?booleanWhether the new subscription should be initialized as paused. Defaults to false.

Returns

Subscription

The new subscription.

Implementation of

MutableSubscribableMap.pipe

Inherited from

AbstractSubscribableMap.pipe

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

NameTypeDescription
toMutableSubscribable<any, M>The mutable subscribable to which to pipe this subscribable's mapped state.
map(fromVal: ReadonlyMap<K, V>, toVal: M) => MThe function to use to transform inputs.
paused?booleanWhether the new subscription should be initialized as paused. Defaults to false.

Returns

Subscription

The new subscription.

Implementation of

MutableSubscribable.pipe

Inherited from

AbstractSubscribableMap.pipe

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

NameTypeDescription
toMutableSubscribableMap<K, V>The mutable subscribable map to which to pipe this map's state.
paused?booleanWhether the new subscription should be initialized as paused. Defaults to false.

Returns

Subscription

The new subscription.

Implementation of

MutableSubscribable.pipe

Inherited from

AbstractSubscribableMap.pipe

Defined in

src/sdk/sub/AbstractSubscribableMap.ts:262


set

set(entries): void

Sets the key-value pairs contained in this map.

Parameters

NameTypeDescription
entriesIterable<[K, V]>The key-value pairs to set.

Returns

void

Implementation of

MutableSubscribable.set

Defined in

src/sdk/sub/MapSubject.ts:44


setValue

setValue(key, value): this

Adds a key-value pair to this map. If this map already contains the specified key, then the existing value stored under the key will be replaced with the new value.

Parameters

NameTypeDescription
keyKThe key to add.
valueVThe value to add.

Returns

this

This map, after the key-value pair has been added.

Implementation of

MutableSubscribableMap.setValue

Defined in

src/sdk/sub/MapSubject.ts:59


sub

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

Subscribes to changes in this subscribable's state.

Parameters

NameTypeDefault valueDescription
handlerSubscribableMapHandler<K, V>undefinedA function which is called when this subscribable's state changes.
initialNotifybooleanfalseWhether to immediately invoke the callback function with this subscribable'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.

Implementation of

MutableSubscribableMap.sub

Inherited from

AbstractSubscribableMap.sub

Defined in

src/sdk/sub/AbstractSubscribableMap.ts:62


unsub

unsub(handler): void

Unsubscribes a callback function from this subscribable.

Parameters

NameTypeDescription
handlerSubscribableMapHandler<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

MutableSubscribable.unsub

Inherited from

AbstractSubscribableMap.unsub

Defined in

src/sdk/sub/AbstractSubscribableMap.ts:77


create

create<K, V>(initialEntries?): MapSubject<K, V>

Creates and returns a new MapSubject.

Type parameters

Name
K
V

Parameters

NameTypeDescription
initialEntries?Iterable<[K, V]>The key-value pairs initially contained in the new map. If not defined, then the new map will initially be empty.

Returns

MapSubject<K, V>

A new MapSubject instance.

Defined in

src/sdk/sub/MapSubject.ts:31