Skip to content

ntcore-ts / @ntcore-ts/react / usePrefixTopicMap

Function: usePrefixTopicMap()

usePrefixTopicMap(prefix, subscribeOptions?): Record<string, PrefixTopicMapEntry>

Defined in: react/src/lib/use-prefix-topic.ts:91

Subscribes to all topics under a NetworkTables prefix and returns a map of every topic name to its latest value and NT type. Updates are batched with requestAnimationFrame so rapid announcements all appear. Use when you need to list or iterate over all topics (e.g. an "all topics" table). For only the latest single update, use usePrefixTopic instead.

Unsubscribes on unmount. Prefix topics are subscribe-only.

Parameters

prefix

string

Topic prefix (e.g. "/SmartDashboard" or "/" for all).

subscribeOptions?

Omit<SubscribeOptions, "prefix">

Optional subscribe options (e.g. { periodic: 0.02 }).

Returns

Record<string, PrefixTopicMapEntry>

Map of topic name to { value, type }. Empty object after first flush when no topics yet.

Released under the MIT License.