Skip to main content

Interface: Consumer<T>

Defined in: src/sdk/data/Consumer.ts:7

A consumer of events which optionally filters event data before passing the consumed events to handlers.

Type Parameters

Type Parameter
T

Properties

isConsumer

readonly isConsumer: true

Defined in: src/sdk/data/Consumer.ts:9

Flags this object as a Consumer.

Methods

atFrequency()

atFrequency(frequency, immediateFirstPublish?): Consumer<T>

Defined in: src/sdk/data/Consumer.ts:33

Caps the event subscription to a specified frequency, in Hz.

Parameters

ParameterTypeDescription
frequencynumberThe frequency, in Hz, to cap to.
immediateFirstPublish?booleanWhether to fire once immediately before throttling.

Returns

Consumer<T>

A new consumer with the applied frequency filter.


handle()

handle(handler, paused?): Subscription

Defined in: src/sdk/data/Consumer.ts:17

Handles an event using the provided event handler.

Parameters

ParameterTypeDescription
handlerHandler<T>The event handler for the event.
paused?booleanWhether the new subscription should be initialized as paused. Defaults to false.

Returns

Subscription

A new subscription for the provided handler.


off()

off(handler): void

Defined in: src/sdk/data/Consumer.ts:25

Disables handling of the event.

Parameters

ParameterTypeDescription
handlerHandler<T>The handler to disable.

Returns

void

Deprecated

This method has been deprecated in favor of using the Subscription object returned by .handle() to manage subscriptions.


onlyAfter()

onlyAfter(deltaTime): Consumer<T>

Defined in: src/sdk/data/Consumer.ts:62

Filters events by time such that events will not be consumed until a minimum duration has passed since the previous event.

Parameters

ParameterTypeDescription
deltaTimenumberThe minimum delta time between events in milliseconds.

Returns

Consumer<T>

A new consumer with the applied change threshold filter.


whenChanged()

whenChanged(): Consumer<T>

Defined in: src/sdk/data/Consumer.ts:54

Filter the subscription to consume only if the value has changed. At all. Really only useful for strings or other events that don't change much.

Returns

Consumer<T>

A new consumer with the applied change threshold filter.


whenChangedBy()

whenChangedBy(amount): Consumer<T>

Defined in: src/sdk/data/Consumer.ts:47

Filter the subscription to consume only when the value has changed by a minimum amount.

Parameters

ParameterTypeDescription
amountnumberThe minimum amount threshold below which the consumer will not consume.

Returns

Consumer<T>

A new consumer with the applied change threshold filter.


withPrecision()

withPrecision(precision): Consumer<T>

Defined in: src/sdk/data/Consumer.ts:40

Quantizes the numerical event data to consume only at the specified decimal precision.

Parameters

ParameterTypeDescription
precisionnumberThe decimal precision to snap to.

Returns

Consumer<T>

A new consumer with the applied precision filter.