Skip to main content

Class: SetSubject<T>

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

A subscribable set whose keys can be freely added and removed.

Extends​

Type Parameters​

Type Parameter
T

Implements​

Properties​

initialNotifyFunc()​

protected readonly initialNotifyFunc: (sub) => void

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

A function which sends initial notifications to subscriptions.

Notifies a subscription of this set's current state.

Parameters​

ParameterTypeDescription
subHandlerSubscription<SubscribableSetHandler<T>>The subscription to notify.

Returns​

void

Inherited from​

AbstractSubscribableSet.initialNotifyFunc


isMutableSubscribable​

readonly isMutableSubscribable: true = true

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

Flags this object as a MutableSubscribable.

Implementation of​

MutableSubscribable.isMutableSubscribable


isMutableSubscribableSet​

readonly isMutableSubscribableSet: true = true

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

Flags this object as a MutableSubscribableSet.

Implementation of​

MutableSubscribableSet.isMutableSubscribableSet


isSubscribable​

readonly isSubscribable: true = true

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

Flags this object as a Subscribable.

Implementation of​

MutableSubscribable.isSubscribable

Inherited from​

AbstractSubscribableSet.isSubscribable


isSubscribableSet​

readonly isSubscribableSet: true = true

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

Flags this object as a SubscribableSet.

Implementation of​

MutableSubscribableSet.isSubscribableSet

Inherited from​

AbstractSubscribableSet.isSubscribableSet


notifyDepth​

protected notifyDepth: number = 0

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

Inherited from​

AbstractSubscribableSet.notifyDepth


onSubDestroyedFunc()​

protected readonly onSubDestroyedFunc: (sub) => void

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

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

Responds to when a subscription to this set is destroyed.

Parameters​

ParameterTypeDescription
subHandlerSubscription<SubscribableSetHandler<T>>The destroyed subscription.

Returns​

void

Inherited from​

AbstractSubscribableSet.onSubDestroyedFunc


singletonSub?​

protected optional singletonSub: HandlerSubscription<SubscribableSetHandler<T>>

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

Inherited from​

AbstractSubscribableSet.singletonSub


subs?​

protected optional subs: HandlerSubscription<SubscribableSetHandler<T>>[]

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

Inherited from​

AbstractSubscribableSet.subs

Accessors​

size​

Get Signature​

get size(): number

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

The number of elements contained in this set.

Returns​

number

The number of elements contained in this set.

Implementation of​

MutableSubscribableSet.size

Inherited from​

AbstractSubscribableSet.size

Methods​

add()​

add(key): this

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

Adds a key to this set.

Parameters​

ParameterTypeDescription
keyTThe key to add.

Returns​

this

This set, after the key has been added.

Implementation of​

MutableSubscribableSet.add


addSubscription()​

protected addSubscription(sub): void

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

Adds a subscription to this set.

Parameters​

ParameterTypeDescription
subHandlerSubscription<SubscribableSetHandler<T>>The subscription to add.

Returns​

void

Inherited from​

AbstractSubscribableSet.addSubscription


clear()​

clear(): void

Defined in: src/sdk/sub/SetSubject.ts:121

Removes all keys from this set.

Returns​

void

Implementation of​

MutableSubscribableSet.clear


delete()​

delete(key): boolean

Defined in: src/sdk/sub/SetSubject.ts:72

Removes a key from this set.

Parameters​

ParameterTypeDescription
keyTThe key to remove.

Returns​

boolean

Whether the key was removed.

Implementation of​

MutableSubscribableSet.delete


get()​

get(): ReadonlySet<T>

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

Gets this item's state.

Returns​

ReadonlySet<T>

This item's state.

Implementation of​

MutableSubscribableSet.get

Overrides​

AbstractSubscribableSet.get


has()​

has(key): boolean

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

Checks whether this set contains a key.

Parameters​

ParameterTypeDescription
keyTThe key to check.

Returns​

boolean

Whether this set contains the specified key.

Implementation of​

MutableSubscribableSet.has

Inherited from​

AbstractSubscribableSet.has


initialNotify()​

protected initialNotify(sub): void

Defined in: src/sdk/sub/AbstractSubscribableSet.ts:154

Notifies a subscription of this set's current state.

Parameters​

ParameterTypeDescription
subHandlerSubscription<SubscribableSetHandler<T>>The subscription to notify.

Returns​

void

Inherited from​

AbstractSubscribableSet.initialNotify


map()​

Call Signature​

map<M>(fn, equalityFunc?): MappedSubject<[ReadonlySet<T>], M>

Defined in: src/sdk/sub/AbstractSubscribableSet.ts:187

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<[ReadonlySet<T>], M>

The mapped subscribable.

Implementation of​

MutableSubscribable.map

Inherited from​

AbstractSubscribableSet.map

Call Signature​

map<M>(fn, equalityFunc, mutateFunc, initialVal): MappedSubject<[ReadonlySet<T>], M>

Defined in: src/sdk/sub/AbstractSubscribableSet.ts:196

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<[ReadonlySet<T>], M>

The mapped subscribable.

Implementation of​

MutableSubscribable.map

Inherited from​

AbstractSubscribableSet.map


notify()​

protected notify(type, key): void

Defined in: src/sdk/sub/AbstractSubscribableSet.ts:76

Notifies subscriptions of a change in this set.

Parameters​

ParameterTypeDescription
typeSubscribableSetEventTypeThe type of change.
keyTThe key related to the change.

Returns​

void

Inherited from​

AbstractSubscribableSet.notify


onSubDestroyed()​

protected onSubDestroyed(sub): void

Defined in: src/sdk/sub/AbstractSubscribableSet.ts:165

Responds to when a subscription to this set is destroyed.

Parameters​

ParameterTypeDescription
subHandlerSubscription<SubscribableSetHandler<T>>The destroyed subscription.

Returns​

void

Inherited from​

AbstractSubscribableSet.onSubDestroyed


pipe()​

Call Signature​

pipe(to, paused?): Subscription

Defined in: src/sdk/sub/AbstractSubscribableSet.ts:224

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, ReadonlySet<T>>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​

MutableSubscribableSet.pipe

Inherited from​

AbstractSubscribableSet.pipe

Call Signature​

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

Defined in: src/sdk/sub/AbstractSubscribableSet.ts:236

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​

MutableSubscribableSet.pipe

Inherited from​

AbstractSubscribableSet.pipe

Call Signature​

pipe(to, paused?): Subscription

Defined in: src/sdk/sub/AbstractSubscribableSet.ts:244

Subscribes to and pipes this set's state to a mutable subscribable set. Whenever a key added or removed event is received through the subscription, the same key will be added to or removed from the other set.

Parameters​
ParameterTypeDescription
toMutableSubscribableSet<T>The mutable subscribable set to which to pipe this set'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​

AbstractSubscribableSet.pipe

Call Signature​

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

Defined in: src/sdk/sub/AbstractSubscribableSet.ts:257

Subscribes to this set's state and pipes a mapped version to a mutable subscribable set. Whenever a key added event is received through the subscription, the key will be transformed by the specified mapping function, and the transformed key will be added to the other set. Whenever a key removed event is received, the transformed key is removed from the other set if and only if no remaining key in this set maps to the same transformed key.

Type Parameters​
Type ParameterDescription
OTThe element type of the set to which to pipe.
Parameters​
ParameterTypeDescription
toMutableSubscribableSet<OT>The mutable subscribable to which to pipe this set's mapped state.
map(fromKey) => OTThe function to use to transform keys.
paused?booleanWhether the new subscription should be initialized as paused. Defaults to false.
Returns​

Subscription

The new subscription.

Implementation of​

UserSetting.pipe

Inherited from​

AbstractSubscribableSet.pipe


set()​

set(keys): void

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

Sets the keys contained in this set.

Parameters​

ParameterTypeDescription
keysIterable<T>The keys to set.

Returns​

void

Implementation of​

MutableSubscribable.set


sub()​

sub(handler, initialNotify, paused): Subscription

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

Subscribes to changes in this subscribable's state.

Parameters​

ParameterTypeDefault valueDescription
handlerSubscribableSetHandler<T>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​

MutableSubscribableSet.sub

Inherited from​

AbstractSubscribableSet.sub


toggle()​

Toggles the presence of a key in this set.

Param​

The key to toggle.

Param​

The state of the key to force. If true, the key will be added to this set. If false, the key will be removed from this set. If not defined, the key will be added to this set if it is not already present and removed if it is already present.

Call Signature​

toggle(key): boolean

Defined in: src/sdk/sub/SetSubject.ts:87

Toggles the presence of a key in this set.

Parameters​
ParameterTypeDescription
keyTThe key to toggle.
Returns​

boolean

Whether the key is present in this set after the toggle operation.

Implementation of​

MutableSubscribableSet.toggle

Call Signature​

toggle(key, force): boolean

Defined in: src/sdk/sub/SetSubject.ts:95

Toggles the presence of a key in this set.

Parameters​
ParameterTypeDescription
keyTThe key to toggle.
forcebooleanThe state of the key to force. If true, the key will be added to this set. If false, the key will be removed from this set.
Returns​

boolean

Whether the key is present in this set after the toggle operation.

Implementation of​

MutableSubscribableSet.toggle


create()​

static create<T>(initialKeys?): SetSubject<T>

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

Creates and returns a new SetSubject.

Type Parameters​

Type Parameter
T

Parameters​

ParameterTypeDescription
initialKeys?Iterable<T, any, any>The keys initially contained in the new set. If not defined, then the new set will be initialized to the empty set.

Returns​

SetSubject<T>

A new SetSubject instance.