Class: GameVarPublisher<E>
A base class for publishers that need to handle simvars with built-in support for pacing callbacks.
Type parameters
Name | Type |
---|---|
E | extends Record <string , any > |
Hierarchy
↳
GameVarPublisher
Constructors
constructor
• new GameVarPublisher<E
>(simVarMap
, bus
, pacer?
): GameVarPublisher
<E
>
Create a SimVarPublisher
Type parameters
Name | Type |
---|---|
E | extends Record <string , any > |
Parameters
Name | Type | Description |
---|---|---|
simVarMap | Map <keyof E & string , SimVarDefinition > | A map of simvar event type keys to a SimVarDefinition. |
bus | EventBus | The EventBus to use for publishing. |
pacer? | PublishPacer <E > | An optional pacer to control the rate of publishing. |
Returns
Overrides
Defined in
src/sdk/instruments/BasePublishers.ts:392
Properties
bus
• Protected
Readonly
bus: EventBus
Inherited from
Defined in
src/sdk/instruments/BasePublishers.ts:10
pacer
• Protected
Readonly
pacer: undefined
| PublishPacer
<E
>
Inherited from
Defined in
src/sdk/instruments/BasePublishers.ts:13
publishActive
• Protected
publishActive: boolean
Inherited from
Defined in
src/sdk/instruments/BasePublishers.ts:12
publisher
• Protected
Readonly
publisher: Publisher
<E
>
Inherited from
Defined in
src/sdk/instruments/BasePublishers.ts:11
simvars
• Protected
Readonly
simvars: Map
<keyof E
& string
, SimVarPublisherEntry
<any
>>
Defined in
src/sdk/instruments/BasePublishers.ts:383
subscribed
• Protected
Readonly
subscribed: Set
<keyof E
& string
>
Defined in
src/sdk/instruments/BasePublishers.ts:384
Methods
getValue
▸ getValue<K
>(topic
): undefined
| E
[K
]
Gets the current value for a topic.
Type parameters
Name | Type |
---|---|
K | extends string |
Parameters
Name | Type | Description |
---|---|---|
topic | K | A topic. |
Returns
undefined
| E
[K
]
The current value for the specified topic.
Defined in
src/sdk/instruments/BasePublishers.ts:479
isPublishing
▸ isPublishing(): boolean
Tells whether or not the publisher is currently active.
Returns
boolean
True if the publisher is active, false otherwise.
Inherited from
Defined in
src/sdk/instruments/BasePublishers.ts:45
onTopicSubscribed
▸ onTopicSubscribed(topic
): void
Responds to when one of this publisher's topics is subscribed to for the first time.
Parameters
Name | Type | Description |
---|---|---|
topic | keyof E & string | The topic that was subscribed to. |
Returns
void
Defined in
src/sdk/instruments/BasePublishers.ts:421
onUpdate
▸ onUpdate(): void
Publish all subscribed data points to the bus.
Returns
void
Overrides
Defined in
src/sdk/instruments/BasePublishers.ts:457
publish
▸ publish<K
>(topic
, data
, sync?
, isCached?
): void
Publish a message if publishing is acpive
Type parameters
Name | Type |
---|---|
K | extends string | number | symbol |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
topic | K | undefined | The topic key to publish to. |
data | E [K ] | undefined | The data type for chosen topic. |
sync | boolean | false | Whether or not the event should be synced to other instruments. Defaults to false . |
isCached | boolean | true | Whether or not the event should be cached. Defaults to true . |
Returns
void
Inherited from
Defined in
src/sdk/instruments/BasePublishers.ts:63
publishTopic
▸ publishTopic(topic
): void
Publishes data to the event bus for a topic.
Parameters
Name | Type | Description |
---|---|---|
topic | keyof E & string | The topic to publish. |
Returns
void
Defined in
src/sdk/instruments/BasePublishers.ts:467
startPublish
▸ startPublish(): void
Start publishing.
Returns
void
Inherited from
Defined in
src/sdk/instruments/BasePublishers.ts:30
stopPublish
▸ stopPublish(): void
Stop publishing.
Returns
void
Inherited from
Defined in
src/sdk/instruments/BasePublishers.ts:37
subscribe
▸ subscribe(data
): void
NOOP - For backwards compatibility.
Parameters
Name | Type | Description |
---|---|---|
data | keyof E | Key of the event type in the simVarMap |
Returns
void
Deprecated
Defined in
src/sdk/instruments/BasePublishers.ts:440
unsubscribe
▸ unsubscribe(data
): void
NOOP - For backwards compatibility.
Parameters
Name | Type | Description |
---|---|---|
data | keyof E | Key of the event type in the simVarMap |
Returns
void
Deprecated
Defined in
src/sdk/instruments/BasePublishers.ts:450