Skip to content

ntcore-ts / @ntcore-ts/react / useStructTopic

Function: useStructTopic()

Call Signature

useStructTopic<T>(name, type, options?): UseStructTopicResult<T>

Defined in: react/src/lib/use-struct-topic.ts:58

Subscribes to a NetworkTables struct topic using a WPILib-style type descriptor (e.g. useStructTopic('/MyTable/PoseStruct', Pose2d)).

Type Parameters

T

T extends object

Parameters

name

string

type

StructTypeDescriptor<T>

options?

UseStructTopicTypeOptions<T>

Returns

UseStructTopicResult<T>

Call Signature

useStructTopic<T>(name, options?): UseStructTopicResult<T>

Defined in: react/src/lib/use-struct-topic.ts:74

Subscribes to a NetworkTables struct topic and returns the latest decoded value. Unsubscribes on unmount.

Reading only: Omit publish in options.

Reading and writing: Pass publish: true or publish: { retained: true } in options. Only call setValue when isReadyToWrite is true.

Subscription is re-created only when nt or name change. Optional options are read at subscribe time.

Type Parameters

T

T extends object | object[]

Parameters

name

string

options?

UseStructTopicOptions<T>

Returns

UseStructTopicResult<T>

Released under the MIT License.