Class: ObjectSubject<T>
Defined in: src/sdk/sub/ObjectSubject.ts:17
A object-valued subscribable subject which supports setting individual properties on the object and notifying subscribers of any changes to those properties.
Type Parameters
Type Parameter |
---|
T extends Record <string , any > |
Implements
MutableSubscribable
<Readonly
<T
>,Partial
<Readonly
<T
>>>
Properties
isMutableSubscribable
readonly
isMutableSubscribable:true
=true
Defined in: src/sdk/sub/ObjectSubject.ts:19
Flags this object as a MutableSubscribable.
Implementation of
MutableSubscribable
.isMutableSubscribable
isSubscribable
readonly
isSubscribable:true
=true
Defined in: src/sdk/sub/ObjectSubject.ts:18
Flags this object as a Subscribable.
Implementation of
MutableSubscribable
.isSubscribable
Methods
get()
get():
Readonly
<T
>
Defined in: src/sdk/sub/ObjectSubject.ts:50
Gets this subject's object.
Returns
Readonly
<T
>
This subject's object.
Implementation of
map()
Call Signature
map<
M
>(fn
,equalityFunc?
):MappedSubject
<[T
],M
>
Defined in: src/sdk/sub/ObjectSubject.ts:240
Maps this subject to a new subscribable.
Type Parameters
Type Parameter |
---|
M |
Parameters
Parameter | Type | Description |
---|---|---|
fn | (input , previousVal? ) => M | The function to use to map to the new subscribable. |
equalityFunc? | (a , b ) => boolean | The function to use to check for equality between mapped values. Defaults to the strict equality comparison (=== ). |
Returns
MappedSubject
<[T
], M
>
The mapped subscribable.
Implementation of
Call Signature
map<
M
>(fn
,equalityFunc
,mutateFunc
,initialVal
):MappedSubject
<[Readonly
<T
>],M
>
Defined in: src/sdk/sub/ObjectSubject.ts:249
Maps this subject to a new subscribable with a persistent, cached value which is mutated when it changes.
Type Parameters
Type Parameter |
---|
M |
Parameters
Parameter | Type | Description |
---|---|---|
fn | (input , previousVal? ) => M | The function to use to map to the new subscribable. |
equalityFunc | (a , b ) => boolean | The function to use to check for equality between mapped values. |
mutateFunc | (oldVal , newVal ) => void | The function to use to change the value of the mapped subscribable. |
initialVal | M | The initial value of the mapped subscribable. |
Returns
MappedSubject
<[Readonly
<T
>], M
>
The mapped subscribable.
Implementation of
pipe()
Call Signature
pipe(
to
,paused?
):Subscription
Defined in: src/sdk/sub/ObjectSubject.ts:277
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
Parameter | Type | Description |
---|---|---|
to | MutableSubscribable <any , 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
Call Signature
pipe<
M
>(to
,map
,paused?
):Subscription
Defined in: src/sdk/sub/ObjectSubject.ts:287
Subscribes to this subscribable's state and pipes a mapped version to a mutable subscribable. Whenever an update of this 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 the other subscribable's state.
Type Parameters
Type Parameter |
---|
M |
Parameters
Parameter | Type | Description |
---|---|---|
to | MutableSubscribable <any , M > | The mutable subscribable to which to pipe this subscribable's mapped state. |
map | (fromVal , toVal ) => 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
set()
Call Signature
set(
value
):void
Defined in: src/sdk/sub/ObjectSubject.ts:102
Sets the values of a subset of the properties of this subject's object and notifies subscribers if any of the values changed.
Parameters
Parameter | Type | Description |
---|---|---|
value | Partial <Readonly <T >> | An object defining the values of the properties to set. |
Returns
void
Implementation of
Call Signature
set<
K
>(key
,value
):void
Defined in: src/sdk/sub/ObjectSubject.ts:108
Sets the value of one of the properties of this subject's object and notifies subscribers if the value changed.
Type Parameters
Type Parameter |
---|
K extends string | number | symbol |
Parameters
Parameter | Type | Description |
---|---|---|
key | K | The property to set. |
value | T [K ] | The new value. |
Returns
void
Implementation of
MutableSubscribable.set
sub()
sub(
handler
,initialNotify
,paused
):Subscription
Defined in: src/sdk/sub/ObjectSubject.ts:55
Subscribes to changes in this subscribable's state.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
handler | ObjectSubjectHandler <T > | undefined | A function which is called when this subscribable's state changes. |
initialNotify | boolean | false | Whether to immediately invoke the callback function with this subscribable'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
unsub()
unsub(
handler
):void
Defined in: src/sdk/sub/ObjectSubject.ts:85
Unsubscribes a callback function from this subscribable.
Parameters
Parameter | Type | Description |
---|---|---|
handler | ObjectSubjectHandler <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
create()
static
create<T
>(v
):ObjectSubject
<T
>
Defined in: src/sdk/sub/ObjectSubject.ts:42
Creates and returns a new ObjectSubject.
Type Parameters
Type Parameter |
---|
T extends Record <string , any > |
Parameters
Parameter | Type | Description |
---|---|---|
v | T | The initial value of the subject. |
Returns
ObjectSubject
<T
>
An ObjectSubject instance.