Class: BasicConsumer<T>
Defined in: src/sdk/data/BasicConsumer.ts:8
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:20
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
readonly
isConsumer:true
=true
Defined in: src/sdk/data/BasicConsumer.ts:10
Flags this object as a Consumer.
Implementation of
Methods
atFrequency()
atFrequency(
frequency
,immediateFirstPublish
):Consumer
<T
>
Defined in: src/sdk/data/BasicConsumer.ts:85
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:27
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
off()
off(
handler
):void
Defined in: src/sdk/data/BasicConsumer.ts:73
Disables handling of the event.
Parameters
Parameter | Type | Description |
---|---|---|
handler | Handler <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.
Implementation of
onlyAfter()
onlyAfter(
deltaTime
):Consumer
<T
>
Defined in: src/sdk/data/BasicConsumer.ts:188
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:169
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:146
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:121
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.