Class: SubscribableUtils
Utility methods for working with Subscribables.
Constructors
constructor
• new SubscribableUtils(): SubscribableUtils
Returns
Methods
NEVER_EQUALITY
▸ NEVER_EQUALITY(): false
An equality function which returns false unconditionally.
Returns
false
false unconditionally.
Defined in
src/sdk/sub/SubscribableUtils.ts:23
NUMERIC_NAN_EQUALITY
▸ NUMERIC_NAN_EQUALITY(a
, b
): boolean
A numeric equality function which returns true
if and only if two numbers are strictly equal or if they are both
NaN
.
Parameters
Name | 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
.
Defined in
src/sdk/sub/SubscribableUtils.ts:17
isMutableSubscribable
▸ isMutableSubscribable<T
, I
>(query
): query is MutableSubscribable<T, I>
Checks if a query is a mutable subscribable.
Type parameters
Name | Type |
---|---|
T | any |
I | T |
Parameters
Name | Type | Description |
---|---|---|
query | unknown | A query. |
Returns
query is MutableSubscribable<T, I>
Whether the query is a mutable subscribable.
Defined in
src/sdk/sub/SubscribableUtils.ts:39
isMutableSubscribableSet
▸ isMutableSubscribableSet<T
>(query
): query is SubscribableSet<T>
Checks if a query is a mutable subscribable set.
Type parameters
Name | Type |
---|---|
T | any |
Parameters
Name | Type | Description |
---|---|---|
query | unknown | A query. |
Returns
query is SubscribableSet<T>
Whether the query is a mutable subscribable set.
Defined in
src/sdk/sub/SubscribableUtils.ts:57
isSubscribable
▸ isSubscribable<T
>(query
): query is Subscribable<T>
Checks if a query is a subscribable.
Type parameters
Name | Type |
---|---|
T | any |
Parameters
Name | Type | Description |
---|---|---|
query | unknown | A query. |
Returns
query is Subscribable<T>
Whether the query is a subscribable.
Defined in
src/sdk/sub/SubscribableUtils.ts:30
isSubscribableSet
▸ isSubscribableSet<T
>(query
): query is SubscribableSet<T>
Checks if a query is a subscribable set.
Type parameters
Name | Type |
---|---|
T | any |
Parameters
Name | Type | Description |
---|---|---|
query | unknown | A query. |
Returns
query is SubscribableSet<T>
Whether the query is a subscribable set.
Defined in
src/sdk/sub/SubscribableUtils.ts:48
pipeMappedSource
▸ pipeMappedSource<S
, T
, U
>(source
, to
, sourceMap
, paused?
): Subscription
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
Name | Type |
---|---|
S | S |
T | T |
U | extends MutableSubscribable <any , T > |
Parameters
Name | 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 : S ) => 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.
Defined in
src/sdk/sub/SubscribableUtils.ts:94
▸ pipeMappedSource<S
, M
, T
, U
>(source
, to
, sourceMap
, pipeMap
, paused?
): Subscription
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
Name | Type |
---|---|
S | S |
M | M |
T | T |
U | extends MutableSubscribable <any , T > |
Parameters
Name | 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 : S ) => Subscribable <M > | A function that maps source values to subscribables whose states are piped to the target. |
pipeMap | (fromVal : M , toVal : T ) => 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.
Defined in
src/sdk/sub/SubscribableUtils.ts:113
pipeOptionalMappedSource
▸ pipeOptionalMappedSource<S
, T
, U
>(source
, to
, onOrphaned
, sourceMap
, paused?
): Subscription
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
Name | Type |
---|---|
S | S |
T | T |
U | extends MutableSubscribable <any , T > |
Parameters
Name | 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 : U ) => 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 : S ) => 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.
Defined in
src/sdk/sub/SubscribableUtils.ts:165
▸ pipeOptionalMappedSource<S
, M
, T
, U
>(source
, to
, onOrphaned
, sourceMap
, pipeMap
, paused?
): Subscription
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
Name | Type |
---|---|
S | S |
M | M |
T | T |
U | extends MutableSubscribable <any , T > |
Parameters
Name | 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 : U ) => 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 : S ) => undefined | Subscribable <M > | A function that maps source values to optional subscribables whose states are piped to the target. |
pipeMap | (fromVal : M , toVal : T ) => 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.
Defined in
src/sdk/sub/SubscribableUtils.ts:191
toSubscribable
▸ toSubscribable<V
, Exclude
>(value
, excludeSubscribables
): Exclude
extends true
? V
extends Subscribable
<any
> ? V
: Subscribable
<V
> : Subscribable
<V
>
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
Name | Type |
---|---|
V | V |
Exclude | extends boolean |
Parameters
Name | 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
: Subscribable
<V
> : Subscribable
<V
>
A subscribable.
Defined in
src/sdk/sub/SubscribableUtils.ts:72