Skip to main content

Abstract Class: AbstractSubscribableSet<T>

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

An abstract implementation of a subscribable set which allows adding, removing, and notifying subscribers.

Extended by

Type Parameters

Type Parameter
T

Implements

Constructors

Constructor

new AbstractSubscribableSet<T>(): AbstractSubscribableSet<T>

Returns

AbstractSubscribableSet<T>

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


isSubscribable

readonly isSubscribable: true = true

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

Flags this object as a Subscribable.

Implementation of

Subscribable.isSubscribable


isSubscribableSet

readonly isSubscribableSet: true = true

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

Flags this object as a SubscribableSet.

Implementation of

SubscribableSet.isSubscribableSet


notifyDepth

protected notifyDepth: number = 0

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


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


singletonSub?

protected optional singletonSub: HandlerSubscription<SubscribableSetHandler<T>>

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


subs?

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

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

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

SubscribableSet.size

Methods

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


get()

abstract get(): ReadonlySet<T>

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

Gets a read-only version of this set.

Returns

ReadonlySet<T>

A read-only version of this set.

Implementation of

Subscribable.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

SubscribableSet.has


initialNotify()

protected initialNotify(sub): void

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

Notifies a subscription of this set's current state.

Parameters

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

Returns

void


map()

Call Signature

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

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

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

Subscribable.map

Call Signature

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

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

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

Subscribable.map


notify()

protected notify(type, key): void

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

Notifies subscriptions of a change in this set.

Parameters

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

Returns

void


onSubDestroyed()

protected onSubDestroyed(sub): void

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

Responds to when a subscription to this set is destroyed.

Parameters

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

Returns

void


pipe()

Call Signature

pipe(to, paused?): Subscription

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

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

Subscribable.pipe

Call Signature

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

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

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 Parameter
M
Parameters
ParameterTypeDescription
toMutableSubscribable<any, M>The mutable subscribable to which to pipe this subscribable's mapped state.
map(fromVal, toVal) => 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

Subscribable.pipe

Call Signature

pipe(to, paused?): Subscription

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

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

SubscribableSet.pipe

Call Signature

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

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

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

SubscribableSet.pipe


sub()

sub(handler, initialNotify, paused): Subscription

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

Subscribes to changes in this set's state.

Parameters

ParameterTypeDefault valueDescription
handlerSubscribableSetHandler<T>undefinedA function which is called when this set's state changes.
initialNotifybooleanfalseWhether to immediately invoke the callback function with this set'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

Subscribable.sub


unsub()

unsub(handler): void

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

Unsubscribes a callback function from this subscribable.

Parameters

ParameterTypeDescription
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

Subscribable.unsub