Skip to main content

Class: SimVarPublisher<Events, IndexedEventRoots>

Defined in: src/sdk/instruments/BasePublishers.ts:144

A base class for publishers that need to handle simvars with built-in support for pacing callbacks.

Extends​

Extended by​

Type Parameters​

Type ParameterDefault type
Events extends Record<string, any>-
IndexedEventRoots extends Record<string, any>Events

Constructors​

Constructor​

new SimVarPublisher<Events, IndexedEventRoots>(entries, bus, pacer?): SimVarPublisher<Events, IndexedEventRoots>

Defined in: src/sdk/instruments/BasePublishers.ts:159

Creates a new instance of SimVarPublisher.

Parameters​

ParameterTypeDescription
entriesIterable<readonly [keyof Events | keyof IndexedEventRoots & string, SimVarPublisherEntry<any>]>Entries describing the SimVars to publish.
busEventBusThe event bus to which to publish.
pacer?PublishPacer<Events>An optional pacer to control the rate of publishing.

Returns​

SimVarPublisher<Events, IndexedEventRoots>

Overrides​

BasePublisher.constructor

Properties​

bus​

protected readonly bus: EventBus

Defined in: src/sdk/instruments/BasePublishers.ts:10

Inherited from​

BasePublisher.bus


indexedSimVars​

protected readonly indexedSimVars: Map<keyof IndexedEventRoots & string, IndexedSimVarPublisherEntry<any>>

Defined in: src/sdk/instruments/BasePublishers.ts:149


pacer​

protected readonly pacer: undefined | PublishPacer<Events>

Defined in: src/sdk/instruments/BasePublishers.ts:13

Inherited from​

BasePublisher.pacer


publishActive​

protected publishActive: boolean

Defined in: src/sdk/instruments/BasePublishers.ts:12

Inherited from​

BasePublisher.publishActive


publisher​

protected readonly publisher: Publisher<Events>

Defined in: src/sdk/instruments/BasePublishers.ts:11

Inherited from​

BasePublisher.publisher


resolvedSimVars​

protected readonly resolvedSimVars: Map<keyof Events & string, ResolvedSimVarPublisherEntry<any>>

Defined in: src/sdk/instruments/BasePublishers.ts:147


subscribed​

protected readonly subscribed: Set<keyof Events & string>

Defined in: src/sdk/instruments/BasePublishers.ts:151


INDEXED_REGEX​

protected readonly static INDEXED_REGEX: RegExp

Defined in: src/sdk/instruments/BasePublishers.ts:145

Methods​

getValue()​

protected getValue<K>(topic): undefined | Events[K]

Defined in: src/sdk/instruments/BasePublishers.ts:343

Gets the current value for a topic.

Type Parameters​

Type Parameter
K extends string

Parameters​

ParameterTypeDescription
topicKA topic.

Returns​

undefined | Events[K]

The current value for the specified topic.


getValueFromEntry()​

protected getValueFromEntry<T>(entry): T

Defined in: src/sdk/instruments/BasePublishers.ts:357

Gets the current value for a resolved topic entry.

Type Parameters​

Type Parameter
T

Parameters​

ParameterTypeDescription
entryResolvedSimVarPublisherEntry<T>An entry for a resolved topic.

Returns​

T

The current value for the specified entry.


handleSubscribedTopic()​

protected handleSubscribedTopic(topic): void

Defined in: src/sdk/instruments/BasePublishers.ts:193

Handles when an event bus topic is subscribed to for the first time.

Parameters​

ParameterTypeDescription
topicstringThe subscribed topic.

Returns​

void


isPublishing()​

isPublishing(): boolean

Defined in: src/sdk/instruments/BasePublishers.ts:45

Tells whether or not the publisher is currently active.

Returns​

boolean

True if the publisher is active, false otherwise.

Inherited from​

BasePublisher.isPublishing


onTopicSubscribed()​

protected onTopicSubscribed(topic): void

Defined in: src/sdk/instruments/BasePublishers.ts:279

Responds to when one of this publisher's topics is subscribed to for the first time.

Parameters​

ParameterTypeDescription
topickeyof Events & stringThe topic that was subscribed to.

Returns​

void


onUpdate()​

onUpdate(): void

Defined in: src/sdk/instruments/BasePublishers.ts:315

Publish all subscribed data points to the bus.

Returns​

void

Overrides​

BasePublisher.onUpdate


publish()​

protected publish<K>(topic, data, sync, isCached): void

Defined in: src/sdk/instruments/BasePublishers.ts:63

Publish a message if publishing is acpive

Type Parameters​

Type Parameter
K extends string | number | symbol

Parameters​

ParameterTypeDefault valueDescription
topicKundefinedThe topic key to publish to.
dataEvents[K]undefinedThe data type for chosen topic.
syncbooleanfalseWhether or not the event should be synced to other instruments. Defaults to false.
isCachedbooleantrueWhether or not the event should be cached. Defaults to true.

Returns​

void

Inherited from​

BasePublisher.publish


publishTopic()​

protected publishTopic(topic): void

Defined in: src/sdk/instruments/BasePublishers.ts:325

Publishes data to the event bus for a topic.

Parameters​

ParameterTypeDescription
topickeyof Events & stringThe topic to publish.

Returns​

void


resolveIndexedSimVar()​

protected resolveIndexedSimVar(topic, entry, index): undefined | string

Defined in: src/sdk/instruments/BasePublishers.ts:250

Attempts to resolve an indexed topic with an index, generating a version of the topic which is mapped to an indexed simvar. The resolved indexed topic can then be published.

Parameters​

ParameterTypeDescription
topickeyof IndexedEventRoots & stringThe topic to resolve.
entryIndexedSimVarPublisherEntry<any>The entry of the topic to resolve.
indexnumberThe index with which to resolve the topic. If not defined, the topic will resolve to itself (without a suffix) and will be mapped the index-1 version of its simvar.

Returns​

undefined | string

The resolved indexed topic, or undefined if the topic could not be resolved with the specified index.


startPublish()​

startPublish(): void

Defined in: src/sdk/instruments/BasePublishers.ts:30

Start publishing.

Returns​

void

Inherited from​

BasePublisher.startPublish


stopPublish()​

stopPublish(): void

Defined in: src/sdk/instruments/BasePublishers.ts:37

Stop publishing.

Returns​

void

Inherited from​

BasePublisher.stopPublish


subscribe()​

subscribe(data): void

Defined in: src/sdk/instruments/BasePublishers.ts:298

NOOP - For backwards compatibility.

Parameters​

ParameterTypeDescription
datakeyof EventsKey of the event type in the simVarMap

Returns​

void

Deprecated​


tryMatchIndexedSubscribedTopic()​

protected tryMatchIndexedSubscribedTopic(topic): void

Defined in: src/sdk/instruments/BasePublishers.ts:208

Checks if a subscribed topic matches one of this publisher's indexed topics, and if so resolves and starts publishing the indexed topic.

Parameters​

ParameterTypeDescription
topicstringThe subscribed topic to check.

Returns​

void


unsubscribe()​

unsubscribe(data): void

Defined in: src/sdk/instruments/BasePublishers.ts:308

NOOP - For backwards compatibility.

Parameters​

ParameterTypeDescription
datakeyof EventsKey of the event type in the simVarMap

Returns​

void

Deprecated​