Skip to main content

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

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

MutableSubscribable.get


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
ParameterTypeDescription
fn(input, previousVal?) => MThe function to use to map to the new subscribable.
equalityFunc?(a, b) => booleanThe 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

MutableSubscribable.map

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
ParameterTypeDescription
fn(input, previousVal?) => MThe function to use to map to the new subscribable.
equalityFunc(a, b) => booleanThe function to use to check for equality between mapped values.
mutateFunc(oldVal, newVal) => voidThe function to use to change the value of the mapped subscribable.
initialValMThe initial value of the mapped subscribable.
Returns

MappedSubject<[Readonly<T>], M>

The mapped subscribable.

Implementation of

MutableSubscribable.map


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
ParameterTypeDescription
toMutableSubscribable<any, T>The mutable subscribable to which to pipe this subscribable's state.
paused?booleanWhether the new subscription should be initialized as paused. Defaults to false.
Returns

Subscription

The new subscription.

Implementation of

MutableSubscribable.pipe

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
ParameterTypeDescription
toMutableSubscribable<any, M>The mutable subscribable to which to pipe this subscribable's mapped state.
map(fromVal, toVal) => MThe function to use to transform inputs.
paused?booleanWhether the new subscription should be initialized as paused. Defaults to false.
Returns

Subscription

The new subscription.

Implementation of

MutableSubscribable.pipe


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
ParameterTypeDescription
valuePartial<Readonly<T>>An object defining the values of the properties to set.
Returns

void

Implementation of

MutableSubscribable.set

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
ParameterTypeDescription
keyKThe property to set.
valueT[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

ParameterTypeDefault valueDescription
handlerObjectSubjectHandler<T>undefinedA function which is called when this subscribable's state changes.
initialNotifybooleanfalseWhether 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.
pausedbooleanfalseWhether the new subscription should be initialized as paused. Defaults to false.

Returns

Subscription

The new subscription.

Implementation of

MutableSubscribable.sub


unsub()

unsub(handler): void

Defined in: src/sdk/sub/ObjectSubject.ts:85

Unsubscribes a callback function from this subscribable.

Parameters

ParameterTypeDescription
handlerObjectSubjectHandler<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

MutableSubscribable.unsub


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

ParameterTypeDescription
vTThe initial value of the subject.

Returns

ObjectSubject<T>

An ObjectSubject instance.