Interface: SubscribableSet<T>
Defined in: src/sdk/sub/SubscribableSet.ts:22
A set which allows others to subscribe to be notified of changes in its state.
Extended by
Type Parameters
Type Parameter |
---|
T |
Properties
isSubscribableSet
readonly
isSubscribableSet:true
Defined in: src/sdk/sub/SubscribableSet.ts:24
Flags this object as a SubscribableSet.
size
readonly
size:number
Defined in: src/sdk/sub/SubscribableSet.ts:27
The number of elements contained in this set.
Methods
get()
get():
ReadonlySet
<T
>
Defined in: src/sdk/sub/SubscribableSet.ts:33
Gets a read-only version of this set.
Returns
ReadonlySet
<T
>
A read-only version of this set.
has()
has(
key
):boolean
Defined in: src/sdk/sub/SubscribableSet.ts:40
Checks whether this set contains a key.
Parameters
Parameter | Type | Description |
---|---|---|
key | T | The key to check. |
Returns
boolean
Whether this set contains the specified key.
pipe()
Call Signature
pipe(
to
,paused?
):Subscription
Defined in: src/sdk/sub/SubscribableSet.ts:59
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
Parameter | 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.
Call Signature
pipe<
M
>(to
,map
,paused?
):Subscription
Defined in: src/sdk/sub/SubscribableSet.ts:71
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
Parameter | Type | Description |
---|---|---|
to | MutableSubscribableSet <M > | The mutable subscribable to which to pipe this set's mapped state. |
map | (input ) => 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.
sub()
sub(
handler
,initialNotify?
,paused?
):Subscription
Defined in: src/sdk/sub/SubscribableSet.ts:50
Subscribes to changes in this set's state.
Parameters
Parameter | Type | Description |
---|---|---|
handler | SubscribableSetHandler <T > | A function which is called when this set's state changes. |
initialNotify? | boolean | 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 | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.