Skip to main content

Class: ConsumerValue<T>

Defined in: src/sdk/data/ConsumerValue.ts:14

Captures the state of a value from a consumer.

Type Parameters​

Type Parameter
T

Implements​

Properties​

canInitialNotify​

readonly canInitialNotify: true = true

Defined in: src/sdk/data/ConsumerValue.ts:16

Whether this subscription supports initial notifications on resume.

Implementation of​

Subscription.canInitialNotify

Accessors​

isAlive​

Get Signature​

get isAlive(): boolean

Defined in: src/sdk/data/ConsumerValue.ts:32

Whether this object is alive. While alive, this object will update its value from its event consumer unless it is paused. Once dead, this object will no longer update its value and cannot be resumed again.

Returns​

boolean

Whether this subscription is alive. Live subscriptions can be freely paused and resumed. Dead subscriptions no longer receive notifications from their sources and will throw an error when attempting to pause or resume them.

Implementation of​

Subscription.isAlive


isPaused​

Get Signature​

get isPaused(): boolean

Defined in: src/sdk/data/ConsumerValue.ts:41

Whether event consumption is currently paused. While paused, this object's value will not update.

Returns​

boolean

Whether this subscription is paused. Paused subscriptions do not receive notifications from their sources until they are resumed.

Implementation of​

Subscription.isPaused

Methods​

destroy()​

destroy(): void

Defined in: src/sdk/data/ConsumerValue.ts:182

Destroys this object. Once destroyed, it will no longer consume events to update its value.

Returns​

void

Implementation of​

Subscription.destroy


get()​

get(): T

Defined in: src/sdk/data/ConsumerValue.ts:69

Gets this item's state.

Returns​

T

This item's state.

Implementation of​

Accessible.get


pause()​

pause(): this

Defined in: src/sdk/data/ConsumerValue.ts:143

Pauses consuming events for this object. Once paused, this object's value will not be updated.

Returns​

this

This object, after it has been paused.

Implementation of​

Subscription.pause


reset()​

reset(initialVal, consumer): this

Defined in: src/sdk/data/ConsumerValue.ts:129

Resets this subject to an initial value and optionally sets a new consumer from which this subject will derive its value. If the consumer is null, then this object's value will not be updated until a non-null consumer is set.

Parameters​

ParameterTypeDefault valueDescription
initialValTundefinedThe initial value to which to reset this object.
consumerConsumer<T> | nullnullAn event consumer. Defaults to null.

Returns​

this

This object, after it has been reset.


resume()​

resume(): this

Defined in: src/sdk/data/ConsumerValue.ts:162

Resumes consuming events for this object. Once resumed, this object's value will be updated from consumed events.

Any initialNotify argument passed to this method is ignored. This object is always immediately notified of its event consumer's value when resumed.

Returns​

this

This object, after it has been resumed.

Implementation of​

Subscription.resume


setConsumer()​

setConsumer(consumer): this

Defined in: src/sdk/data/ConsumerValue.ts:79

Sets the consumer from which this object derives its value. If the consumer is null, this object's value will not be updated until a non-null consumer is set.

Parameters​

ParameterTypeDescription
consumerConsumer<T> | nullAn event consumer.

Returns​

this

This object, after its consumer has been set.


setConsumerWithDefault()​

setConsumerWithDefault(consumer, defaultVal): this

Defined in: src/sdk/data/ConsumerValue.ts:102

Sets the consumer from which this object derives its value and designates a default value to set if an event is not immediately consumed from the new consumer when this object is resumed. If the consumer is null, then this object's value will be set to the default value.

Parameters​

ParameterTypeDescription
consumerConsumer<T> | nullAn event consumer.
defaultValTThe default value to set if the new consumer is null or if an event is not immediately consumed from the new consumer when this object is resumed.

Returns​

this

This object, after its consumer has been set.


withLifecycle()​

withLifecycle(lifecycle): this

Defined in: src/sdk/data/ConsumerValue.ts:198

Attaches a lifecycle to the subscription.

Parameters​

ParameterTypeDescription
lifecycleReadonlyLifecycleThe lifecycle to attach.

Returns​

this

Implementation of​

Subscription.withLifecycle


create()​

static create<T>(consumer, initialValue): ConsumerValue<T>

Defined in: src/sdk/data/ConsumerValue.ts:193

Creates a new ConsumerValue.

Type Parameters​

Type Parameter
T

Parameters​

ParameterTypeDescription
consumerConsumer<T> | nullThe consumer to track.
initialValueTThe initial value.

Returns​

ConsumerValue<T>

The created ConsumerValue.