Skip to main content

Class: MapSubject<K, V>

Defined in: src/sdk/sub/MapSubject.ts:8

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

Extends​

Type Parameters​

Type Parameter
K
V

Implements​

Properties​

initialNotifyFunc()​

protected readonly initialNotifyFunc: (sub) => void

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:28

A function which sends initial notifications to subscriptions.

Notifies a subscription of this map's current state.

Parameters​

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

Returns​

void

Inherited from​

AbstractSubscribableMap.initialNotifyFunc


isMutableSubscribable​

readonly isMutableSubscribable: true = true

Defined in: src/sdk/sub/MapSubject.ts:9

Flags this object as a MutableSubscribable.

Implementation of​

MutableSubscribable.isMutableSubscribable


isMutableSubscribableMap​

readonly isMutableSubscribableMap: true = true

Defined in: src/sdk/sub/MapSubject.ts:10

Flags this object as a MutableSubscribableMap.

Implementation of​

MutableSubscribableMap.isMutableSubscribableMap


isSubscribable​

readonly isSubscribable: true = true

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:14

Flags this object as a Subscribable.

Implementation of​

MutableSubscribable.isSubscribable

Inherited from​

AbstractSubscribableMap.isSubscribable


isSubscribableMap​

readonly isSubscribableMap: true = true

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:15

Flags this object as a SubscribableMap.

Implementation of​

MutableSubscribableMap.isSubscribableMap

Inherited from​

AbstractSubscribableMap.isSubscribableMap


notifyDepth​

protected notifyDepth: number = 0

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:25

Inherited from​

AbstractSubscribableMap.notifyDepth


onSubDestroyedFunc()​

protected readonly onSubDestroyedFunc: (sub) => void

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:31

A function which responds to when a subscription to this subscribable is destroyed.

Responds to when a subscription to this map is destroyed.

Parameters​

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

Returns​

void

Inherited from​

AbstractSubscribableMap.onSubDestroyedFunc


singletonSub?​

protected optional singletonSub: HandlerSubscription<SubscribableMapHandler<K, V>>

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:22

Inherited from​

AbstractSubscribableMap.singletonSub


subs?​

protected optional subs: HandlerSubscription<SubscribableMapHandler<K, V>>[]

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:24

Inherited from​

AbstractSubscribableMap.subs

Accessors​

size​

Get Signature​

get size(): number

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:18

The number of elements contained in this map.

Returns​

number

The number of elements contained in this map.

Implementation of​

MutableSubscribableMap.size

Inherited from​

AbstractSubscribableMap.size

Methods​

addSubscription()​

protected addSubscription(sub): void

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:37

Adds a subscription to this map.

Parameters​

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

Returns​

void

Inherited from​

AbstractSubscribableMap.addSubscription


clear()​

clear(): void

Defined in: src/sdk/sub/MapSubject.ts:85

Removes all key-value pairs from this map.

Returns​

void

Implementation of​

MutableSubscribableMap.clear


delete()​

delete(key): boolean

Defined in: src/sdk/sub/MapSubject.ts:73

Removes a key-value pair from this map.

Parameters​

ParameterTypeDescription
keyKThe key to remove.

Returns​

boolean

Whether the key-value pair was removed.

Implementation of​

MutableSubscribableMap.delete


get()​

get(): ReadonlyMap<K, V>

Defined in: src/sdk/sub/MapSubject.ts:36

Gets this item's state.

Returns​

ReadonlyMap<K, V>

This item's state.

Implementation of​

MutableSubscribableMap.get

Overrides​

AbstractSubscribableMap.get


getValue()​

getValue(key): V | undefined

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:57

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

Parameters​

ParameterTypeDescription
keyKThe key under which the value to get is stored.

Returns​

V | undefined

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


has()​

has(key): boolean

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:52

Checks whether this map contains a key.

Parameters​

ParameterTypeDescription
keyKThe key to check.

Returns​

boolean

Whether this map contains the specified key.

Implementation of​

MutableSubscribableMap.has

Inherited from​

AbstractSubscribableMap.has


initialNotify()​

protected initialNotify(sub): void

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:160

Notifies a subscription of this map's current state.

Parameters​

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

Returns​

void

Inherited from​

AbstractSubscribableMap.initialNotify


map()​

Call Signature​

map<M>(fn, equalityFunc?): MappedSubject<[ReadonlyMap<K, V>], M>

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:193

Maps this subscribable to a new subscribable.

Type Parameters​
Type Parameter
M
Parameters​
ParameterTypeDescription
fn(input, previousVal?) => MThe function to use to map to the new subscribable.
equalityFunc?(a, b) => 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

Call Signature​

map<M>(fn, equalityFunc, mutateFunc, initialVal): MappedSubject<[ReadonlyMap<K, V>], M>

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:202

Maps this subscribable to a new subscribable with a persistent, cached value which is mutated when it changes.

Type Parameters​
Type Parameter
M
Parameters​
ParameterTypeDescription
fn(input, previousVal?) => MThe function to use to map to the new subscribable.
equalityFunc(a, b) => booleanThe function to use to check for equality between mapped values.
mutateFunc(oldVal, newVal) => 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


notify()​

protected notify(type, key, value): void

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:82

Notifies subscriptions of a change in this map.

Parameters​

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

Returns​

void

Inherited from​

AbstractSubscribableMap.notify


onSubDestroyed()​

protected onSubDestroyed(sub): void

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:171

Responds to when a subscription to this map is destroyed.

Parameters​

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

Returns​

void

Inherited from​

AbstractSubscribableMap.onSubDestroyed


pipe()​

Call Signature​

pipe(to, paused?): Subscription

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:230

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​
ParameterTypeDescription
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

Call Signature​

pipe<OI, OV>(to, map, paused?): Subscription

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:242

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​
Type ParameterDefault typeDescription
OI-The input type of the mutable subscribable to which to pipe.
OVunknownThe value type of the mutable subscribable to which to pipe.
Parameters​
ParameterTypeDescription
toMutableSubscribable<any, OI>The mutable subscribable to which to pipe this subscribable's mapped state.
map(fromVal, toVal) => OIThe 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

Call Signature​

pipe(to, paused?): Subscription

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:251

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​
ParameterTypeDescription
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​

UserSetting.pipe

Inherited from​

AbstractSubscribableMap.pipe


set()​

set(entries): void

Defined in: src/sdk/sub/MapSubject.ts:44

Sets the key-value pairs contained in this map.

Parameters​

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

Returns​

void

Implementation of​

MutableSubscribable.set


setValue()​

setValue(key, value): this

Defined in: src/sdk/sub/MapSubject.ts:59

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​

ParameterTypeDescription
keyKThe key to add.
valueVThe value to add.

Returns​

this

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

Implementation of​

MutableSubscribableMap.setValue


sub()​

sub(handler, initialNotify, paused): Subscription

Defined in: src/sdk/sub/AbstractSubscribableMap.ts:62

Subscribes to changes in this subscribable's state.

Parameters​

ParameterTypeDefault 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


create()​

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

Defined in: src/sdk/sub/MapSubject.ts:31

Creates and returns a new MapSubject.

Type Parameters​

Type Parameter
K
V

Parameters​

ParameterTypeDescription
initialEntries?Iterable<[K, V], any, any>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.