Class: BasicConsumer<T>
Defined in: src/sdk/data/BasicConsumer.ts:9
A basic implementation of Consumer.
Type Parameters
| Type Parameter |
|---|
T |
Implements
Consumer<T>
Constructors
Constructor
new BasicConsumer<
T>(subscribe,state,currentHandler?):BasicConsumer<T>
Defined in: src/sdk/data/BasicConsumer.ts:19
Creates an instance of a Consumer.
Parameters
| Parameter | Type | Description |
|---|---|---|
subscribe | (handler, paused) => Subscription | A function which subscribes a handler to the source of this consumer's events. |
state | any | The state for the consumer to track. |
currentHandler? | (data, state, next) => void | The current build filter handler stack, if any. |
Returns
BasicConsumer<T>
Properties
isConsumer
readonlyisConsumer:true=true
Defined in: src/sdk/data/BasicConsumer.ts:11
Flags this object as a Consumer.
Implementation of
Methods
atFrequency()
atFrequency(
frequency,immediateFirstPublish):Consumer<T>
Defined in: src/sdk/data/BasicConsumer.ts:47
Caps the event subscription to a specified frequency, in Hz.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
frequency | number | undefined | The frequency, in Hz, to cap to. |
immediateFirstPublish | boolean | true | Whether to fire once immediately before throttling. |
Returns
Consumer<T>
A new consumer with the applied frequency filter.
Implementation of
handle()
handle(
handler,paused):Subscription
Defined in: src/sdk/data/BasicConsumer.ts:26
Handles an event using the provided event handler.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
handler | Handler<T> | undefined | The event handler for the event. |
paused | boolean | false | Whether the new subscription should be initialized as paused. Defaults to false. |
Returns
A new subscription for the provided handler.
Implementation of
onlyAfter()
onlyAfter(
deltaTime):Consumer<T>
Defined in: src/sdk/data/BasicConsumer.ts:150
Filters events by time such that events will not be consumed until a minimum duration has passed since the previous event.
Parameters
| Parameter | Type | Description |
|---|---|---|
deltaTime | number | The minimum delta time between events in milliseconds. |
Returns
Consumer<T>
A new consumer with the applied change threshold filter.
Implementation of
whenChanged()
whenChanged():
Consumer<T>
Defined in: src/sdk/data/BasicConsumer.ts:131
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.
Implementation of
whenChangedBy()
whenChangedBy(
amount):Consumer<T>
Defined in: src/sdk/data/BasicConsumer.ts:108
Filter the subscription to consume only when the value has changed by a minimum amount.
Parameters
| Parameter | Type | Description |
|---|---|---|
amount | number | The minimum amount threshold below which the consumer will not consume. |
Returns
Consumer<T>
A new consumer with the applied change threshold filter.
Implementation of
withPrecision()
withPrecision(
precision):Consumer<T>
Defined in: src/sdk/data/BasicConsumer.ts:83
Quantizes the numerical event data to consume only at the specified decimal precision.
Parameters
| Parameter | Type | Description |
|---|---|---|
precision | number | The decimal precision to snap to. |
Returns
Consumer<T>
A new consumer with the applied precision filter.