Class: GameVarPublisher<E>
Defined in: src/sdk/instruments/BasePublishers.ts:382
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:392
Create a SimVarPublisher
Parameters
Parameter | 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
GameVarPublisher
<E
>
Overrides
Properties
bus
protected
readonly
bus:EventBus
Defined in: src/sdk/instruments/BasePublishers.ts:10
Inherited from
pacer
protected
readonly
pacer:undefined
|PublishPacer
<E
>
Defined in: src/sdk/instruments/BasePublishers.ts:13
Inherited from
publishActive
protected
publishActive:boolean
Defined in: src/sdk/instruments/BasePublishers.ts:12
Inherited from
publisher
protected
readonly
publisher:Publisher
<E
>
Defined in: src/sdk/instruments/BasePublishers.ts:11
Inherited from
simvars
protected
readonly
simvars:Map
<keyofE
&string
,SimVarPublisherEntry
<any
>>
Defined in: src/sdk/instruments/BasePublishers.ts:383
subscribed
protected
readonly
subscribed:Set
<keyofE
&string
>
Defined in: src/sdk/instruments/BasePublishers.ts:384
Methods
getValue()
protected
getValue<K
>(topic
):undefined
|E
[K
]
Defined in: src/sdk/instruments/BasePublishers.ts:479
Gets the current value for a topic.
Type Parameters
Type Parameter |
---|
K extends string |
Parameters
Parameter | Type | Description |
---|---|---|
topic | K | A topic. |
Returns
undefined
| E
[K
]
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
onTopicSubscribed()
protected
onTopicSubscribed(topic
):void
Defined in: src/sdk/instruments/BasePublishers.ts:421
Responds to when one of this publisher's topics is subscribed to for the first time.
Parameters
Parameter | Type | Description |
---|---|---|
topic | keyof E & string | The topic that was subscribed to. |
Returns
void
onUpdate()
onUpdate():
void
Defined in: src/sdk/instruments/BasePublishers.ts:457
Publish all subscribed data points to the bus.
Returns
void
Overrides
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
Parameter | 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
publishTopic()
protected
publishTopic(topic
):void
Defined in: src/sdk/instruments/BasePublishers.ts:467
Publishes data to the event bus for a topic.
Parameters
Parameter | Type | Description |
---|---|---|
topic | keyof E & string | The topic to publish. |
Returns
void
startPublish()
startPublish():
void
Defined in: src/sdk/instruments/BasePublishers.ts:30
Start publishing.
Returns
void
Inherited from
stopPublish()
stopPublish():
void
Defined in: src/sdk/instruments/BasePublishers.ts:37
Stop publishing.
Returns
void
Inherited from
subscribe()
subscribe(
data
):void
Defined in: src/sdk/instruments/BasePublishers.ts:440
NOOP - For backwards compatibility.
Parameters
Parameter | Type | Description |
---|---|---|
data | keyof E | Key of the event type in the simVarMap |
Returns
void
Deprecated
unsubscribe()
unsubscribe(
data
):void
Defined in: src/sdk/instruments/BasePublishers.ts:450
NOOP - For backwards compatibility.
Parameters
Parameter | Type | Description |
---|---|---|
data | keyof E | Key of the event type in the simVarMap |
Returns
void