Class NetworkTablesTopic<T>

Type Parameters

Hierarchy

  • NetworkTablesTopic

Constructors

  • Creates a new topic. This should only be done after the base NTCore client has been initialized.

    Type Parameters

    • T extends string | number | boolean | string[] | ArrayBuffer | boolean[] | number[]

    Parameters

    • client: PubSubClient

      The client that owns the topic.

    • name: string

      The name of the topic.

    • typeInfo: NetworkTablesTypeInfo

      The type info for the topic.

    • Optional defaultValue: T

      The default value for the topic.

    Returns NetworkTablesTopic<T>

Properties

_announced: boolean
_id?: number
_lastChangedTime?: number
_name: string
_publisher: boolean
_pubuid?: number
_subscribers: Map<number, {
    callback: ((_) => void);
    immediateNotify: boolean;
    options: {
        all?: boolean;
        periodic?: number;
        prefix?: boolean;
        topicsonly?: boolean;
    };
}>

Type declaration

  • callback: ((_) => void)
      • (_): void
      • Parameters

        • _: null | T

        Returns void

  • immediateNotify: boolean
  • options: {
        all?: boolean;
        periodic?: number;
        prefix?: boolean;
        topicsonly?: boolean;
    }
    • Optional all?: boolean
    • Optional periodic?: number
    • Optional prefix?: boolean
    • Optional topicsonly?: boolean
client: PubSubClient
value: null | T

Accessors

  • get subscribers(): Map<number, {
        callback: ((_) => void);
        immediateNotify: boolean;
        options: {
            all?: boolean;
            periodic?: number;
            prefix?: boolean;
            topicsonly?: boolean;
        };
    }>
  • Gets the subscribers to the topic.

    Returns Map<number, {
        callback: ((_) => void);
        immediateNotify: boolean;
        options: {
            all?: boolean;
            periodic?: number;
            prefix?: boolean;
            topicsonly?: boolean;
        };
    }>

    The subscribers to the topic.

Methods

  • Publishes the topic.

    Parameters

    • properties: {
          persistent?: boolean;
          retained?: boolean;
      } = {}

      The properties to publish the topic with.

      • Optional persistent?: boolean
      • Optional retained?: boolean
    • Optional id: number

      The UID of the publisher.

    Returns void

  • Sets the properties of the topic.

    Parameters

    • Optional persistent: boolean

      If true, the last set value will be periodically saved to persistent storage on the server and be restored during server startup. Topics with this property set to true will not be deleted by the server when the last publisher stops publishing.

    • Optional retained: boolean

      Topics with this property set to true will not be deleted by the server when the last publisher stops publishing.

    Returns void

  • Creates a new subscriber. This should only be called by the PubSubClient.

    Parameters

    • callback: ((_) => void)

      The callback to call when the topic value changes.

        • (_): void
        • Parameters

          • _: null | T

          Returns void

    • immediateNotify: boolean = false

      Whether to immediately notify the subscriber of the current value.

    • options: {
          all?: boolean;
          periodic?: number;
          prefix?: boolean;
          topicsonly?: boolean;
      } = {}

      The options for the subscriber.

      • Optional all?: boolean
      • Optional periodic?: number
      • Optional prefix?: boolean
      • Optional topicsonly?: boolean
    • Optional id: number

      The UID of the subscriber.

    • save: boolean = true

      Whether to save the subscriber.

    Returns number

    The UID of the subscriber.

  • 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

  • Updates the value of the topic. This should only be called by the PubSubClient.

    Parameters

    • value: T

      The value to update.

    • lastChangedTime: number

      The server time of the last value change.

    Returns void

Generated using TypeDoc