Skip to content

API reference / @chanx-js/client / react / UseTopicResult

Interface: UseTopicResult<Ref> ​

Defined in: packages/client/src/react/useTopic.ts:23

Extends ​

Type Parameters ​

Type Parameter
Ref extends TopicRef

Properties ​

clearMessages ​

ts
clearMessages: () => void;

Defined in: packages/client/src/react/useTopic.ts:24

Returns ​

void


handle ​

ts
handle: 
  | TopicHandle<ToServerOf<Ref>, ToClientOf<Ref>>
  | null;

Defined in: packages/client/src/react/useTopic.ts:30

The topic's handle while joined.


lastMessage ​

ts
lastMessage: 
  | TopicMessage<Ref>
  | null;

Defined in: packages/client/src/core/controller.ts:460

Inherited from ​

TopicSnapshot.lastMessage


messages ​

ts
messages: TopicMessage<Ref>[];

Defined in: packages/client/src/core/controller.ts:461

Inherited from ​

TopicSnapshot.messages


request ​

ts
request: (message, options?) => Promise<ChanxMessage>;

Defined in: packages/client/src/react/useTopic.ts:28

Send on the topic and wait for the reply carrying the same ref.

Parameters ​

ParameterType
messageToServerOf<Ref>
options?RequestOptions

Returns ​

Promise<ChanxMessage>


send ​

ts
send: (message) => void;

Defined in: packages/client/src/react/useTopic.ts:26

Send on the topic.

Parameters ​

ParameterType
messageToServerOf<Ref>

Returns ​

void


status ​

ts
status: SocketStatus;

Defined in: packages/client/src/core/controller.ts:457

Inherited from ​

TopicSnapshot.status


subscribed ​

ts
subscribed: boolean;

Defined in: packages/client/src/core/controller.ts:459

Whether the server has confirmed the subscription.

Inherited from ​

TopicSnapshot.subscribed


terminate ​

ts
terminate: (code?, reason?) => void;

Defined in: packages/client/src/react/useTopic.ts:32

Close the socket for every component sharing it, not just this one.

Parameters ​

ParameterType
code?number
reason?string

Returns ​

void

MIT licensed