Class: BasicConsumer<T>
A basic implementation of Consumer.
Type parameters
Name |
---|
T |
Implements
Consumer
<T
>
Constructors
constructor
• new BasicConsumer<T
>(subscribe
, state?
, currentHandler?
): BasicConsumer
<T
>
Creates an instance of a Consumer.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
subscribe | (handler : Handler <T >, paused : boolean ) => 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 : T , state : any , next : Handler <T >) => void | The current build filter handler stack, if any. |
Returns
Defined in
src/sdk/data/BasicConsumer.ts:20
Properties
isConsumer
• Readonly
isConsumer: true
Flags this object as a Consumer.
Implementation of
Defined in
src/sdk/data/BasicConsumer.ts:10
Methods
atFrequency
▸ atFrequency(frequency
, immediateFirstPublish?
): Consumer
<T
>
Caps the event subscription to a specified frequency, in Hz.
Parameters
Name | 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
Defined in
src/sdk/data/BasicConsumer.ts:85
handle
▸ handle(handler
, paused?
): Subscription
Handles an event using the provided event handler.
Parameters
Name | 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
Defined in
src/sdk/data/BasicConsumer.ts:27
off
▸ off(handler
): void
Disables handling of the event.
Parameters
Name | 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
Defined in
src/sdk/data/BasicConsumer.ts:73
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
Name | 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
Defined in
src/sdk/data/BasicConsumer.ts:188
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.
Implementation of
Defined in
src/sdk/data/BasicConsumer.ts:169
whenChangedBy
▸ whenChangedBy(amount
): Consumer
<T
>
Filter the subscription to consume only when the value has changed by a minimum amount.
Parameters
Name | 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
Defined in
src/sdk/data/BasicConsumer.ts:146
withPrecision
▸ withPrecision(precision
): Consumer
<T
>
Quantizes the numerical event data to consume only at the specified decimal precision.
Parameters
Name | Type | Description |
---|---|---|
precision | number | The decimal precision to snap to. |
Returns
Consumer
<T
>
A new consumer with the applied precision filter.
Implementation of
Defined in
src/sdk/data/BasicConsumer.ts:121