ntcore-ts / @ntcore-ts/client / NetworkTablesPrefixTopic
Class: NetworkTablesPrefixTopic
Defined in: pubsub/prefix-topic.ts:14
Extends
NetworkTablesBaseTopic<NetworkTablesTypes>
Constructors
Constructor
new NetworkTablesPrefixTopic(
client,name):NetworkTablesPrefixTopic
Defined in: pubsub/prefix-topic.ts:27
Creates a new topic. This should only be done after the base NTCore client has been initialized.
Parameters
client
PubSubClient
The client that owns the topic.
name
string
The name of the topic.
Returns
NetworkTablesPrefixTopic
Overrides
NetworkTablesBaseTopic<NetworkTablesTypes>.constructor
Properties
_announceParams
protected_announceParams: {id:number;name:string;properties: {cached?:boolean;persistent?:boolean;retained?:boolean; };pubuid?:number;type:string; } |null
Defined in: pubsub/base-topic.ts:23
Inherited from
NetworkTablesBaseTopic._announceParams
_lastChangedTime?
protectedoptional_lastChangedTime?:number
Defined in: pubsub/base-topic.ts:22
Inherited from
NetworkTablesBaseTopic._lastChangedTime
client
protectedclient:PubSubClient
Defined in: pubsub/base-topic.ts:19
Inherited from
NetworkTablesBaseTopic.client
type
readonlytype:"prefix"='prefix'
Defined in: pubsub/prefix-topic.ts:15
Overrides
NetworkTablesBaseTopic.type
Accessors
announced
Get Signature
get announced():
boolean
Defined in: pubsub/base-topic.ts:68
Whether the topic has been announced.
Returns
boolean
Whether the topic has been announced.
Inherited from
NetworkTablesBaseTopic.announced
id
Get Signature
get id():
number|undefined
Defined in: pubsub/base-topic.ts:44
Gets the ID of the topic.
Returns
number | undefined
The ID of the topic.
Inherited from
NetworkTablesBaseTopic.id
lastChangedTime
Get Signature
get lastChangedTime():
number|undefined
Defined in: pubsub/base-topic.ts:60
Gets the server time of the last value change.
Returns
number | undefined
The server time of the last value change.
Inherited from
NetworkTablesBaseTopic.lastChangedTime
name
Get Signature
get name():
string
Defined in: pubsub/base-topic.ts:52
Gets the name of the topic.
Returns
string
The name of the topic.
Inherited from
NetworkTablesBaseTopic.name
subscribers
Get Signature
get subscribers():
Map<number, {callback:CallbackFn<T>;options:SubscribeOptions; }>
Defined in: pubsub/base-topic.ts:76
Gets the subscribers to the topic.
Returns
Map<number, { callback: CallbackFn<T>; options: SubscribeOptions; }>
The subscribers to the topic.
Inherited from
NetworkTablesBaseTopic.subscribers
Methods
announce()
announce(
params):void
Defined in: pubsub/base-topic.ts:101
Marks the topic as announced. This should only be called by the PubSubClient.
Parameters
params
The parameters of the announcement.
id
number = integerSchema
name
string = ...
properties
{ cached?: boolean; persistent?: boolean; retained?: boolean; } = topicPropertiesSchema
properties.cached?
boolean = ...
properties.persistent?
boolean = ...
properties.retained?
boolean = ...
pubuid?
number = ...
type
string = typeStringSchema
Returns
void
Inherited from
NetworkTablesBaseTopic.announce
isPrefix()
isPrefix():
this is NetworkTablesPrefixTopic
Defined in: pubsub/base-topic.ts:36
Returns
this is NetworkTablesPrefixTopic
Inherited from
NetworkTablesBaseTopic.isPrefix
isRegular()
isRegular(): this is NetworkTablesTopic<string | number | boolean | string[] | Uint8Array<ArrayBufferLike> | boolean[] | number[], string | number | boolean | string[] | Uint8Array<ArrayBufferLike> | boolean[] | number[]>
Defined in: pubsub/base-topic.ts:32
Returns
this is NetworkTablesTopic<string | number | boolean | string[] | Uint8Array<ArrayBufferLike> | boolean[] | number[], string | number | boolean | string[] | Uint8Array<ArrayBufferLike> | boolean[] | number[]>
Inherited from
NetworkTablesBaseTopic.isRegular
resubscribeAll()
resubscribeAll(
client):void
Defined in: pubsub/prefix-topic.ts:109
Resubscribes all local subscribers.
Parameters
client
PubSubClient
The client to resubscribe with.
Returns
void
Overrides
NetworkTablesBaseTopic.resubscribeAll
setProperties()
setProperties(
properties?):Promise<{method:"properties";params: {ack?:boolean;name:string;update: {cached?:boolean;persistent?:boolean;retained?:boolean; }; }; }>
Defined in: pubsub/base-topic.ts:196
Sets the properties of the topic.
Parameters
properties?
Topic properties to update (e.g. { persistent: true, retained: true }).
cached?
boolean = ...
persistent?
boolean = ...
retained?
boolean = ...
Returns
Promise<{ method: "properties"; params: { ack?: boolean; name: string; update: { cached?: boolean; persistent?: boolean; retained?: boolean; }; }; }>
The server's response.
Inherited from
NetworkTablesBaseTopic.setProperties
subscribe()
subscribe(
callback,options?):number
Defined in: pubsub/prefix-topic.ts:51
Creates a new subscriber.
Parameters
callback
CallbackFn<string | number | boolean | string[] | Uint8Array<ArrayBufferLike> | boolean[] | number[]>
The callback to call when the topic value changes.
options?
Omit<SubscribeOptions, "prefix"> = {}
The options for the subscriber. immediateNotify is client-side only and replays cached matching subtopic values (not sent to the NT server).
Returns
number
The UID of the subscriber.
Overrides
NetworkTablesBaseTopic.subscribe
toProtocolSubscribeOptions()
protectedtoProtocolSubscribeOptions(options?):Omit<SubscribeOptions,"prefix"|"immediateNotify">
Defined in: pubsub/base-topic.ts:179
Strips client-only subscribe options (e.g. immediateNotify) before sending to the NT server.
Parameters
options?
Omit<SubscribeOptions, "prefix"> = {}
The subscriber options, possibly including client-only fields.
Returns
Omit<SubscribeOptions, "prefix" | "immediateNotify">
Protocol subscribe options.
Inherited from
NetworkTablesBaseTopic.toProtocolSubscribeOptions
unannounce()
unannounce():
void
Defined in: pubsub/base-topic.ts:108
Marks the topic as unannounced. This should only be called by the PubSubClient.
Returns
void
Inherited from
NetworkTablesBaseTopic.unannounce
unsubscribe()
unsubscribe(
subuid,removeCallback?):void
Defined in: pubsub/base-topic.ts:154
Removes a subscriber
Parameters
subuid
number
The UID of the subscriber.
removeCallback?
boolean = true
Whether to remove the callback. Leave this as true unless you know what you're doing.
Returns
void
Inherited from
NetworkTablesBaseTopic.unsubscribe
unsubscribeAll()
unsubscribeAll():
void
Defined in: pubsub/base-topic.ts:168
Removes all local subscribers.
Returns
void
Inherited from
NetworkTablesBaseTopic.unsubscribeAll
updateValue()
updateValue(
params,value,serverTime):void
Defined in: pubsub/prefix-topic.ts:124
Updates the value of a subtopic. Notifies all subscribers of the change.
Parameters
params
The params of the subtopic
id
number = integerSchema
name
string = ...
properties
{ cached?: boolean; persistent?: boolean; retained?: boolean; } = topicPropertiesSchema
properties.cached?
boolean = ...
properties.persistent?
boolean = ...
properties.retained?
boolean = ...
pubuid?
number = ...
type
string = typeStringSchema
value
string | number | boolean | string[] | Uint8Array<ArrayBufferLike> | boolean[] | number[] | null
The value of the subtopic
serverTime
number
The time the value was updated
Returns
void