API reference / @chanx-js/client / vue / useTopic
Function: useTopic()
ts
function useTopic<D, T>(
descriptor,
topic,
options?
): UseTopicResult<T>;Defined in: packages/client/src/vue/index.ts:342
Join one topic, typed from that topic throughout:
ts
const { lastMessage, send } = useTopic(hub, hub.topics.roomTopic.with({ room_name }));Same lifecycle as useChannel. The topic may be a ref (or a computed): a new topic rejoins.
Type Parameters
| Type Parameter |
|---|
D extends ChannelDescriptor<any, any, any, any> |
T extends TopicRef<ChanxMessage, ChanxMessage, string> |
Parameters
| Parameter | Type |
|---|---|
descriptor | D |
topic | MaybeRef<T> |
options | Omit<TopicControllerOptions<AddressOf<D>, T>, "params" | "queryParams"> & ReactiveConnectOptions |