Skip to main content

Class: SetSubject<T>

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

Type parameters

Name
T

Hierarchy

Implements

Properties

initialNotifyFunc

Protected Readonly initialNotifyFunc: (sub: HandlerSubscription<SubscribableSetHandler<T>>) => void

A function which sends initial notifications to subscriptions.

Type declaration

▸ (sub): void

A function which sends initial notifications to subscriptions.

Parameters
NameType
subHandlerSubscription<SubscribableSetHandler<T>>
Returns

void

Inherited from

AbstractSubscribableSet.initialNotifyFunc

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:28


isMutableSubscribable

Readonly isMutableSubscribable: true

Flags this object as a MutableSubscribable.

Implementation of

MutableSubscribable.isMutableSubscribable

Defined in

src/sdk/sub/SetSubject.ts:9


isMutableSubscribableSet

Readonly isMutableSubscribableSet: true

Flags this object as a MutableSubscribableSet.

Implementation of

MutableSubscribableSet.isMutableSubscribableSet

Defined in

src/sdk/sub/SetSubject.ts:10


isSubscribable

Readonly isSubscribable: true

Flags this object as a Subscribable.

Implementation of

MutableSubscribable.isSubscribable

Inherited from

AbstractSubscribableSet.isSubscribable

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:14


isSubscribableSet

Readonly isSubscribableSet: true

Flags this object as a SubscribableSet.

Implementation of

MutableSubscribableSet.isSubscribableSet

Inherited from

AbstractSubscribableSet.isSubscribableSet

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:15


notifyDepth

Protected notifyDepth: number = 0

Inherited from

AbstractSubscribableSet.notifyDepth

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:25


onSubDestroyedFunc

Protected Readonly onSubDestroyedFunc: (sub: HandlerSubscription<SubscribableSetHandler<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
NameType
subHandlerSubscription<SubscribableSetHandler<T>>
Returns

void

Inherited from

AbstractSubscribableSet.onSubDestroyedFunc

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:31


singletonSub

Protected Optional singletonSub: HandlerSubscription<SubscribableSetHandler<T>>

Inherited from

AbstractSubscribableSet.singletonSub

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:22


subs

Protected Optional subs: HandlerSubscription<SubscribableSetHandler<T>>[]

Inherited from

AbstractSubscribableSet.subs

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:24

Accessors

size

get size(): number

The number of elements contained in this set.

Returns

number

Implementation of

MutableSubscribableSet.size

Inherited from

AbstractSubscribableSet.size

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:18

Methods

add

add(key): this

Adds a key to this set.

Parameters

NameTypeDescription
keyTThe key to add.

Returns

this

This set, after the key has been added.

Implementation of

MutableSubscribableSet.add

Defined in

src/sdk/sub/SetSubject.ts:59


addSubscription

addSubscription(sub): void

Adds a subscription to this set.

Parameters

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

Returns

void

Inherited from

AbstractSubscribableSet.addSubscription

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:37


clear

clear(): void

Removes all keys from this set.

Returns

void

Implementation of

MutableSubscribableSet.clear

Defined in

src/sdk/sub/SetSubject.ts:121


delete

delete(key): boolean

Removes a key from this set.

Parameters

NameTypeDescription
keyTThe key to remove.

Returns

boolean

Whether the key was removed.

Implementation of

MutableSubscribableSet.delete

Defined in

src/sdk/sub/SetSubject.ts:72


get

get(): ReadonlySet<T>

Gets this item's state.

Returns

ReadonlySet<T>

This item's state.

Implementation of

MutableSubscribableSet.get

Overrides

AbstractSubscribableSet.get

Defined in

src/sdk/sub/SetSubject.ts:36


has

has(key): boolean

Checks whether this set contains a key.

Parameters

NameTypeDescription
keyTThe key to check.

Returns

boolean

Whether this set contains the specified key.

Implementation of

MutableSubscribableSet.has

Inherited from

AbstractSubscribableSet.has

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:52


initialNotify

initialNotify(sub): void

Notifies a subscription of this set's current state.

Parameters

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

Returns

void

Inherited from

AbstractSubscribableSet.initialNotify

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:167


map

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

Maps this subscribable to a new subscribable.

Type parameters

Name
M

Parameters

NameTypeDescription
fn(input: ReadonlySet<T>, 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<[ReadonlySet<T>], M>

The mapped subscribable.

Implementation of

MutableSubscribable.map

Inherited from

AbstractSubscribableSet.map

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:200

map<M>(fn, equalityFunc, mutateFunc, initialVal): MappedSubject<[ReadonlySet<T>], 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: ReadonlySet<T>, 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<[ReadonlySet<T>], M>

The mapped subscribable.

Implementation of

MutableSubscribable.map

Inherited from

AbstractSubscribableSet.map

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:209


notify

notify(type, key): void

Notifies subscriptions of a change in this set.

Parameters

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

Returns

void

Inherited from

AbstractSubscribableSet.notify

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:89


onSubDestroyed

onSubDestroyed(sub): void

Responds to when a subscription to this set is destroyed.

Parameters

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

Returns

void

Inherited from

AbstractSubscribableSet.onSubDestroyed

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:178


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, 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

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:237

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

MutableSubscribableSet.pipe

Inherited from

AbstractSubscribableSet.pipe

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:247

pipe(to, paused?): Subscription

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

NameTypeDescription
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

MutableSubscribable.pipe

Inherited from

AbstractSubscribableSet.pipe

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:255

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

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

Name
M

Parameters

NameTypeDescription
toMutableSubscribableSet<M>The mutable subscribable to which to pipe this set's mapped state.
map(fromKey: T) => MThe 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

MutableSubscribable.pipe

Inherited from

AbstractSubscribableSet.pipe

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:267


set

set(keys): void

Sets the keys contained in this set.

Parameters

NameTypeDescription
keysIterable<T>The keys to set.

Returns

void

Implementation of

MutableSubscribable.set

Defined in

src/sdk/sub/SetSubject.ts:44


sub

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

Subscribes to changes in this subscribable's state.

Parameters

NameTypeDefault 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

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:57


toggle

toggle(key): boolean

Toggles the presence of a key in this set.

Parameters

NameTypeDescription
keyTThe key to toggle.

Returns

boolean

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

Implementation of

MutableSubscribableSet.toggle

Defined in

src/sdk/sub/SetSubject.ts:87

toggle(key, force): boolean

Toggles the presence of a key in this set.

Parameters

NameTypeDescription
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

Defined in

src/sdk/sub/SetSubject.ts:95


unsub

unsub(handler): void

Unsubscribes a callback function from this subscribable.

Parameters

NameTypeDescription
handlerSubscribableSetHandler<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.

Implementation of

MutableSubscribable.unsub

Inherited from

AbstractSubscribableSet.unsub

Defined in

src/sdk/sub/AbstractSubscribableSet.ts:72


create

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

Creates and returns a new SetSubject.

Type parameters

Name
T

Parameters

NameTypeDescription
initialKeys?Iterable<T>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.

Defined in

src/sdk/sub/SetSubject.ts:31