Class: SubscribableUtils
Defined in: src/sdk/sub/SubscribableUtils.ts:9
Utility methods for working with Subscribables.
Constructors
Constructor
new SubscribableUtils():
SubscribableUtils
Returns
SubscribableUtils
Methods
isMutableSubscribable()
static
isMutableSubscribable<T
,I
>(query
):query is MutableSubscribable<T, I>
Defined in: src/sdk/sub/SubscribableUtils.ts:39
Checks if a query is a mutable subscribable.
Type Parameters
Type Parameter | Default type |
---|---|
T | any |
I | T |
Parameters
Parameter | Type | Description |
---|---|---|
query | unknown | A query. |
Returns
query is MutableSubscribable<T, I>
Whether the query is a mutable subscribable.
isMutableSubscribableSet()
static
isMutableSubscribableSet<T
>(query
):query is SubscribableSet<T>
Defined in: src/sdk/sub/SubscribableUtils.ts:57
Checks if a query is a mutable subscribable set.
Type Parameters
Type Parameter | Default type |
---|---|
T | any |
Parameters
Parameter | Type | Description |
---|---|---|
query | unknown | A query. |
Returns
query is SubscribableSet<T>
Whether the query is a mutable subscribable set.
isSubscribable()
static
isSubscribable<T
>(query
):query is Subscribable<T>
Defined in: src/sdk/sub/SubscribableUtils.ts:30
Checks if a query is a subscribable.
Type Parameters
Type Parameter | Default type |
---|---|
T | any |
Parameters
Parameter | Type | Description |
---|---|---|
query | unknown | A query. |
Returns
query is Subscribable<T>
Whether the query is a subscribable.
isSubscribableSet()
static
isSubscribableSet<T
>(query
):query is SubscribableSet<T>
Defined in: src/sdk/sub/SubscribableUtils.ts:48
Checks if a query is a subscribable set.
Type Parameters
Type Parameter | Default type |
---|---|
T | any |
Parameters
Parameter | Type | Description |
---|---|---|
query | unknown | A query. |
Returns
query is SubscribableSet<T>
Whether the query is a subscribable set.
NEVER_EQUALITY()
readonly
static
NEVER_EQUALITY():false
Defined in: src/sdk/sub/SubscribableUtils.ts:23
An equality function which returns false unconditionally.
Returns
false
false unconditionally.
NUMERIC_NAN_EQUALITY()
readonly
static
NUMERIC_NAN_EQUALITY(a
,b
):boolean
Defined in: src/sdk/sub/SubscribableUtils.ts:17
A numeric equality function which returns true
if and only if two numbers are strictly equal or if they are both
NaN
.
Parameters
Parameter | Type | Description |
---|---|---|
a | number | The first number to compare. |
b | number | The second number to compare. |
Returns
boolean
Whether the two numbers are strictly equal or both NaN
.
pipeMappedSource()
Call Signature
static
pipeMappedSource<S
,T
,U
>(source
,to
,sourceMap
,paused?
):Subscription
Defined in: src/sdk/sub/SubscribableUtils.ts:94
Subscribes to a source subscribable and pipes the state of a subscribable mapped from the source subscribable's state to a target mutable subscribable. When the subscription is created, a pipe is established to the target subscribable. Whenever an update of the source's state is received through the subscription, the input of the pipe will be changed to a subscribable mapped from the new source state.
Type Parameters
Type Parameter |
---|
S |
T |
U extends MutableSubscribable <any , T > |
Parameters
Parameter | Type | Description |
---|---|---|
source | Subscribable <S > | The source subscribable from which to map subscribables whose states are piped to the target. |
to | U | The target subscribable. |
sourceMap | (source ) => Subscribable <T > | A function that maps source values to subscribables whose states are piped to the target. |
paused? | boolean | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.
Call Signature
static
pipeMappedSource<S
,M
,T
,U
>(source
,to
,sourceMap
,pipeMap
,paused?
):Subscription
Defined in: src/sdk/sub/SubscribableUtils.ts:113
Subscribes to a source subscribable and pipes a transformed version of the state of a subscribable mapped from the source subscribable's state to a target mutable subscribable. When the subscription is created, a pipe that transforms inputs is established to the target subscribable. Whenever an update of the source's state is received through the subscription, the input of the pipe will be changed to a subscribable mapped from the new source state.
Type Parameters
Type Parameter |
---|
S |
M |
T |
U extends MutableSubscribable <any , T > |
Parameters
Parameter | Type | Description |
---|---|---|
source | Subscribable <S > | The source subscribable from which to map subscribables whose states are piped to the target. |
to | U | The target subscribable. |
sourceMap | (source ) => Subscribable <M > | A function that maps source values to subscribables whose states are piped to the target. |
pipeMap | (fromVal , toVal ) => T | The function to use to transform pipe inputs. |
paused? | boolean | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.
pipeOptionalMappedSource()
Call Signature
static
pipeOptionalMappedSource<S
,T
,U
>(source
,to
,onOrphaned
,sourceMap
,paused?
):Subscription
Defined in: src/sdk/sub/SubscribableUtils.ts:165
Subscribes to a source subscribable and pipes the state of an optional subscribable mapped from the source subscribable's state to a target mutable subscribable. When the subscription is created, a pipe is established to the target subscribable. Whenever an update of the source's state is received through the subscription, the input of the pipe will be changed to a subscribable mapped from the new source state. If the source state can't be mapped to a subscribable, then a default value (if defined) is used to set the state of the target subscribable.
Type Parameters
Type Parameter |
---|
S |
T |
U extends MutableSubscribable <any , T > |
Parameters
Parameter | Type | Description |
---|---|---|
source | Subscribable <S > | The source subscribable from which to map optional subscribables whose states are piped to the target. |
to | U | The target subscribable. |
onOrphaned | undefined | (to ) => void | A function that selects a default value to use to set the state of the target subscribable when the source state can't be mapped to a subscribable. The current value of the target subscribable is passed to the function. If not defined, then the target subscribable is left unchanged when the source state can't be mapped to a subscribable. |
sourceMap | (source ) => undefined | Subscribable <T > | A function that maps source values to optional subscribables whose states are piped to the target. |
paused? | boolean | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.
Call Signature
static
pipeOptionalMappedSource<S
,M
,T
,U
>(source
,to
,onOrphaned
,sourceMap
,pipeMap
,paused?
):Subscription
Defined in: src/sdk/sub/SubscribableUtils.ts:191
Subscribes to a source subscribable and pipes a transformed version of the state of a subscribable mapped from the source subscribable's state to a target mutable subscribable. When the subscription is created, a pipe that transforms inputs is established to the target subscribable. Whenever an update of the source's state is received through the subscription, the input of the pipe will be changed to a subscribable mapped from the new source state.
Type Parameters
Type Parameter |
---|
S |
M |
T |
U extends MutableSubscribable <any , T > |
Parameters
Parameter | Type | Description |
---|---|---|
source | Subscribable <S > | The source subscribable from which to map optional subscribables whose states are piped to the target. |
to | U | The target subscribable. |
onOrphaned | undefined | (to ) => void | A function that selects a default value to use to set the state of the target subscribable when the source state can't be mapped to a subscribable. The current value of the target subscribable is passed to the function. The default value will not be transformed by pipeMap . If not defined, then the target subscribable is left unchanged when the source state can't be mapped to a subscribable. |
sourceMap | (source ) => undefined | Subscribable <M > | A function that maps source values to optional subscribables whose states are piped to the target. |
pipeMap | (fromVal , toVal ) => T | The function to use to transform pipe inputs. |
paused? | boolean | Whether the new subscription should be initialized as paused. Defaults to false . |
Returns
The new subscription.
toSubscribable()
static
toSubscribable<V
,Exclude
>(value
,excludeSubscribables
):Exclude
extendstrue
?V
extendsSubscribable
<any
> ?V
<V
> :Subscribable
<V
> :Subscribable
<V
>
Defined in: src/sdk/sub/SubscribableUtils.ts:72
Converts a value to a subscribable.
If the excludeSubscribables
argument is true
and the value is already a subscribable, then the value is
returned unchanged. Otherwise, a new subscribable whose state is always equal to the value will be created and
returned.
Type Parameters
Type Parameter |
---|
V |
Exclude extends boolean |
Parameters
Parameter | Type | Description |
---|---|---|
value | V | The value to convert to a subscribable. |
excludeSubscribables | Exclude | Whether to return subscribable values as-is instead of wrapping them in another subscribable. |
Returns
Exclude
extends true
? V
extends Subscribable
<any
> ? V
<V
> : Subscribable
<V
> : Subscribable
<V
>
A subscribable.