Skip to main content

Class: GameVarPublisher<E>

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

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

Extends​

Type Parameters​

Type Parameter
E extends Record<string, any>

Constructors​

Constructor​

new GameVarPublisher<E>(simVarMap, bus, pacer?): GameVarPublisher<E>

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

Create a SimVarPublisher

Parameters​

ParameterTypeDescription
simVarMapMap<keyof E & string, SimVarDefinition>A map of simvar event type keys to a SimVarDefinition.
busEventBusThe EventBus to use for publishing.
pacer?PublishPacer<E>An optional pacer to control the rate of publishing.

Returns​

GameVarPublisher<E>

Overrides​

BasePublisher.constructor

Properties​

bus​

protected readonly bus: EventBus

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

Inherited from​

BasePublisher.bus


pacer​

protected readonly pacer: PublishPacer<E> | undefined

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<E>

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

Inherited from​

BasePublisher.publisher


simvars​

protected readonly simvars: Map<keyof E & string, SimVarPublisherEntry<any>>

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


subscribed​

protected readonly subscribed: Set<keyof E & string>

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

Methods​

getValue()​

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

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

Gets the current value for a topic.

Type Parameters​

Type Parameter
K extends string

Parameters​

ParameterTypeDescription
topicKA topic.

Returns​

E[K] | undefined

The current value for the specified topic.


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:392

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

Parameters​

ParameterTypeDescription
topickeyof E & stringThe topic that was subscribed to.

Returns​

void


onUpdate()​

onUpdate(): void

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

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.
dataE[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:418

Publishes data to the event bus for a topic.

Parameters​

ParameterTypeDescription
topickeyof E & stringThe topic to publish.

Returns​

void


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