ntcore-ts-client
    Preparing search index...

    Class NetworkTablesPrefixTopic

    Hierarchy

    Index

    Constructors

    Properties

    _announceParams:
        | null
        | {
            id: number;
            name: string;
            properties: { cached?: boolean; persistent?: boolean; retained?: boolean };
            pubuid?: number;
            type:
                | "string"
                | "boolean"
                | "float"
                | "double"
                | "int"
                | "json"
                | "raw"
                | "rpc"
                | "msgpack"
                | "protobuf"
                | "boolean[]"
                | "double[]"
                | "int[]"
                | "float[]"
                | "string[]";
        }
    _lastChangedTime?: number
    client: PubSubClient
    type: "prefix" = 'prefix'

    Accessors

    • get subscribers(): Map<
          number,
          {
              callback: CallbackFn<T>;
              options: {
                  all?: boolean;
                  periodic?: number;
                  prefix?: boolean;
                  topicsonly?: boolean;
              };
          },
      >

      Gets the subscribers to the topic.

      Returns Map<
          number,
          {
              callback: CallbackFn<T>;
              options: {
                  all?: boolean;
                  periodic?: number;
                  prefix?: boolean;
                  topicsonly?: boolean;
              };
          },
      >

      The subscribers to the topic.

    Methods

    • Marks the topic as announced. This should only be called by the PubSubClient.

      Parameters

      • params: {
            id: number;
            name: string;
            properties: { cached?: boolean; persistent?: boolean; retained?: boolean };
            pubuid?: number;
            type:
                | "string"
                | "boolean"
                | "float"
                | "double"
                | "int"
                | "json"
                | "raw"
                | "rpc"
                | "msgpack"
                | "protobuf"
                | "boolean[]"
                | "double[]"
                | "int[]"
                | "float[]"
                | "string[]";
        }

        The parameters of the announcement.

      Returns void

    • Sets the properties of the topic.

      Parameters

      • Optionalpersistent: 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.

      • Optionalretained: boolean

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

      Returns Promise<{ method: "properties"; params: { ack: boolean; name: string } }>

      The server's response.

    • Creates a new subscriber.

      Parameters

      • callback: CallbackFn<
            | string
            | number
            | boolean
            | string[]
            | ArrayBuffer
            | boolean[]
            | number[],
        >

        The callback to call when the topic value changes.

      • options: Omit<
            {
                all?: boolean;
                periodic?: number;
                prefix?: boolean;
                topicsonly?: boolean;
            },
            "prefix",
        > = {}

        The options for the subscriber.

      • Optionalid: 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 a subtopic. Notifies all subscribers of the change.

      Parameters

      • params: {
            id: number;
            name: string;
            properties: { cached?: boolean; persistent?: boolean; retained?: boolean };
            pubuid?: number;
            type:
                | "string"
                | "boolean"
                | "float"
                | "double"
                | "int"
                | "json"
                | "raw"
                | "rpc"
                | "msgpack"
                | "protobuf"
                | "boolean[]"
                | "double[]"
                | "int[]"
                | "float[]"
                | "string[]";
        }

        The params of the subtopic

      • value: string | number | boolean | string[] | ArrayBuffer | boolean[] | number[]

        The value of the subtopic

      • serverTime: number

        The time the value was updated

      Returns void