Skip to main content

Class: HandlerSubscription<HandlerType>

Defined in: src/sdk/sub/HandlerSubscription.ts:7

A Subscription which executes a handler function every time it receives a notification.

Extended by​

Type Parameters​

Type Parameter
HandlerType extends (...args) => void

Implements​

Constructors​

Constructor​

new HandlerSubscription<HandlerType>(handler, initialNotifyFunc?, onDestroy?): HandlerSubscription<HandlerType>

Defined in: src/sdk/sub/HandlerSubscription.ts:37

Constructor.

Parameters​

ParameterTypeDescription
handlerHandlerTypeThis subscription's handler. The handler will be called each time this subscription receives a notification from its source.
initialNotifyFunc?(sub) => voidA function which sends initial notifications to this subscription. If not defined, this subscription will not support initial notifications.
onDestroy?(sub) => voidA function which is called when this subscription is destroyed.

Returns​

HandlerSubscription<HandlerType>

Properties​

canInitialNotify​

readonly canInitialNotify: boolean

Defined in: src/sdk/sub/HandlerSubscription.ts:27

Whether this subscription supports initial notifications on resume.

Implementation of​

Subscription.canInitialNotify


handler​

readonly handler: HandlerType

Defined in: src/sdk/sub/HandlerSubscription.ts:38

This subscription's handler. The handler will be called each time this subscription receives a notification from its source.


isAlive​

readonly isAlive: true = true

Defined in: src/sdk/sub/HandlerSubscription.ts:15

Whether this subscription is alive. Live subscriptions can be freely paused and resumed. Dead subscriptions no longer receive notifications from their sources and will throw an error when attempting to pause or resume them.

Implementation of​

Subscription.isAlive


isPaused​

readonly isPaused: false = false

Defined in: src/sdk/sub/HandlerSubscription.ts:24

Whether this subscription is paused. Paused subscriptions do not receive notifications from their sources until they are resumed.

Note that !isAlive implies isPaused for HandlerSubscription

Implementation of​

Subscription.isPaused

Methods​

destroy()​

destroy(): void

Defined in: src/sdk/sub/HandlerSubscription.ts:88

Destroys this subscription. Once destroyed, this subscription will no longer receive notifications from its source and will throw an error when attempting to pause or resume it.

Returns​

void

Implementation of​

Subscription.destroy


initialNotify()​

initialNotify(): void

Defined in: src/sdk/sub/HandlerSubscription.ts:49

Sends an initial notification to this subscription.

Returns​

void

Throws​

Error if this subscription is not alive.


pause()​

pause(): this

Defined in: src/sdk/sub/HandlerSubscription.ts:58

Pauses this subscription. Once paused, this subscription will not receive notifications from its source until it is resumed.

Returns​

this

This subscription, after it has been paused.

Throws​

Error if this subscription is not alive.

Implementation of​

Subscription.pause


resume()​

resume(initialNotify): this

Defined in: src/sdk/sub/HandlerSubscription.ts:69

Resumes this subscription. Once resumed, this subscription will receive notifications from its source.

Parameters​

ParameterTypeDefault valueDescription
initialNotifybooleanfalseWhether to immediately send a notification to this subscription's handler when it is resumed if this subscription supports initial notifications. Defaults to false.

Returns​

this

This subscription, after it has been resumed.

Throws​

Error if this subscription is not alive.

Implementation of​

Subscription.resume


withLifecycle()​

withLifecycle(lifecycle): this

Defined in: src/sdk/sub/HandlerSubscription.ts:101

Attaches a lifecycle to the subscription.

Parameters​

ParameterTypeDescription
lifecycleReadonlyLifecycleThe lifecycle to attach.

Returns​

this

Implementation of​

Subscription.withLifecycle