Skip to main content

Interface: Consumer<T>

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

Type parameters

Name
T

Implemented by

Properties

isConsumer

Readonly isConsumer: true

Flags this object as a Consumer.

Defined in

src/sdk/data/Consumer.ts:9

Methods

atFrequency

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

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

Parameters

NameTypeDescription
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.

Defined in

src/sdk/data/Consumer.ts:33


handle

handle(handler, paused?): Subscription

Handles an event using the provided event handler.

Parameters

NameTypeDescription
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.

Defined in

src/sdk/data/Consumer.ts:17


off

off(handler): void

Disables handling of the event.

Parameters

NameTypeDescription
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.

Defined in

src/sdk/data/Consumer.ts:25


onlyAfter

onlyAfter(deltaTime): Consumer<T>

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

Parameters

NameTypeDescription
deltaTimenumberThe minimum delta time between events in milliseconds.

Returns

Consumer<T>

A new consumer with the applied change threshold filter.

Defined in

src/sdk/data/Consumer.ts:62


whenChanged

whenChanged(): Consumer<T>

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.

Defined in

src/sdk/data/Consumer.ts:54


whenChangedBy

whenChangedBy(amount): Consumer<T>

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

Parameters

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

Returns

Consumer<T>

A new consumer with the applied change threshold filter.

Defined in

src/sdk/data/Consumer.ts:47


withPrecision

withPrecision(precision): Consumer<T>

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

Parameters

NameTypeDescription
precisionnumberThe decimal precision to snap to.

Returns

Consumer<T>

A new consumer with the applied precision filter.

Defined in

src/sdk/data/Consumer.ts:40