Class: AbstractSubscribableSet<T>
An abstract implementation of a subscribable set which allows adding, removing, and notifying subscribers.
Type parameters
Name |
---|
T |
Hierarchy
AbstractSubscribableSet
Implements
SubscribableSet
<T
>Subscribable
<ReadonlySet
<T
>>
Constructors
constructor
• new AbstractSubscribableSet<T
>(): AbstractSubscribableSet
<T
>
Type parameters
Name |
---|
T |
Returns
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
Name | Type |
---|---|
sub | HandlerSubscription <SubscribableSetHandler <T >> |
Returns
void
Defined in
src/sdk/sub/AbstractSubscribableSet.ts:28
isSubscribable
• Readonly
isSubscribable: true
Flags this object as a Subscribable.
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableSet.ts:14
isSubscribableSet
• Readonly
isSubscribableSet: true
Flags this object as a SubscribableSet.
Implementation of
SubscribableSet.isSubscribableSet
Defined in
src/sdk/sub/AbstractSubscribableSet.ts:15
notifyDepth
• Protected
notifyDepth: number
= 0
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
Name | Type |
---|---|
sub | HandlerSubscription <SubscribableSetHandler <T >> |
Returns
void
Defined in
src/sdk/sub/AbstractSubscribableSet.ts:31
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
size(): number
The number of elements contained in this set.
Returns
number
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableSet.ts:18
Methods
addSubscription
▸ addSubscription(sub
): void
Adds a subscription to this set.
Parameters
Name | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableSetHandler <T >> | The subscription to add. |
Returns
void
Defined in
src/sdk/sub/AbstractSubscribableSet.ts:37
get
▸ get(): ReadonlySet
<T
>
Gets a read-only version of this set.
Returns
ReadonlySet
<T
>
A read-only version of this set.
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableSet.ts:49
has
▸ has(key
): boolean
Checks whether this set contains a key.
Parameters
Name | Type | Description |
---|---|---|
key | T | The key to check. |
Returns
boolean
Whether this set contains the specified key.
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableSet.ts:52
initialNotify
▸ initialNotify(sub
): void
Notifies a subscription of this set's current state.
Parameters
Name | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableSetHandler <T >> | The subscription to notify. |
Returns
void
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
Name | Type | Description |
---|---|---|
fn | (input : ReadonlySet <T >, previousVal? : M ) => M | The function to use to map to the new subscribable. |
equalityFunc? | (a : M , b : M ) => boolean | The 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
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
Name | Type | Description |
---|---|---|
fn | (input : ReadonlySet <T >, previousVal? : M ) => M | The function to use to map to the new subscribable. |
equalityFunc | (a : M , b : M ) => boolean | The function to use to check for equality between mapped values. |
mutateFunc | (oldVal : M , newVal : M ) => void | The function to use to change the value of the mapped subscribable. |
initialVal | M | The initial value of the mapped subscribable. |
Returns
MappedSubject
<[ReadonlySet
<T
>], M
>
The mapped subscribable.
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableSet.ts:209
notify
▸ notify(type
, key
): void
Notifies subscriptions of a change in this set.
Parameters
Name | Type | Description |
---|---|---|
type | SubscribableSetEventType | The type of change. |
key | T | The key related to the change. |
Returns
void
Defined in
src/sdk/sub/AbstractSubscribableSet.ts:89
onSubDestroyed
▸ onSubDestroyed(sub
): void
Responds to when a subscription to this set is destroyed.
Parameters
Name | Type | Description |
---|---|---|
sub | HandlerSubscription <SubscribableSetHandler <T >> | The destroyed subscription. |
Returns
void
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
Name | Type | Description |
---|---|---|
to | MutableSubscribable <any , ReadonlySet <T >> | The mutable subscribable to which to pipe this subscribable's state. |
paused? | boolean | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.
Implementation of
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
Name | Type | Description |
---|---|---|
to | MutableSubscribable <any , M > | The mutable subscribable to which to pipe this subscribable's mapped state. |
map | (fromVal : ReadonlySet <T >, toVal : M ) => M | The function to use to transform inputs. |
paused? | boolean | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.
Implementation of
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
Name | Type | Description |
---|---|---|
to | MutableSubscribableSet <T > | The mutable subscribable set to which to pipe this set's state. |
paused? | boolean | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.
Implementation of
SubscribableSet.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
Name | Type | Description |
---|---|---|
to | MutableSubscribableSet <M > | The mutable subscribable to which to pipe this set's mapped state. |
map | (fromKey : T ) => M | The function to use to transform keys. |
paused? | boolean | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.
Implementation of
SubscribableSet.pipe
Defined in
src/sdk/sub/AbstractSubscribableSet.ts:267
sub
▸ sub(handler
, initialNotify?
, paused?
): Subscription
Subscribes to changes in this set's state.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
handler | SubscribableSetHandler <T > | undefined | A function which is called when this set's state changes. |
initialNotify | boolean | false | Whether 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. |
paused | boolean | false | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.
Implementation of
Defined in
src/sdk/sub/AbstractSubscribableSet.ts:57
unsub
▸ unsub(handler
): void
Unsubscribes a callback function from this subscribable.
Parameters
Name | Type | Description |
---|---|---|
handler | SubscribableSetHandler <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
Defined in
src/sdk/sub/AbstractSubscribableSet.ts:72