@@ -13,7 +13,8 @@ type UseDataChannelReturnType<T extends string | undefined = undefined> = {
13
13
14
14
/**
15
15
* The `useDataChannel` hook returns the ability to send and receive messages.
16
- * By optionally passing a `topic`, you can narrow down which messages are returned in the messages array.
16
+ * Pass an optional `topic` to narrow down which messages are returned in the messages array.
17
+ *
17
18
* @remarks
18
19
* There is only one data channel. Passing a `topic` does not open a new data channel.
19
20
* It is only used to filter out messages with no or a different `topic`.
@@ -23,23 +24,23 @@ type UseDataChannelReturnType<T extends string | undefined = undefined> = {
23
24
* // Send messages to all participants via the 'chat' topic.
24
25
* const { message: latestMessage, send } = useDataChannel('chat', (msg) => console.log("message received", msg));
25
26
* ```
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * // Receive all messages (no topic filtering)
31
+ * const { message: latestMessage, send } = useDataChannel((msg) => console.log("message received", msg));
32
+ * ```
33
+ *
26
34
* @public
27
35
*/
28
36
export function useDataChannel < T extends string > (
29
37
topic : T ,
30
38
onMessage ?: ( msg : ReceivedDataMessage < T > ) => void ,
31
39
) : UseDataChannelReturnType < T > ;
40
+
32
41
/**
33
- * The `useDataChannel` hook returns the ability to send and receive messages.
34
- * @remarks
35
- * There is only one data channel. Passing a `topic` does not open a new data channel.
36
- * It is only used to filter out messages with no or a different `topic`.
42
+ * Overload for `useDataChannel` without a topic. See {@link (useDataChannel:1)} for information and usage examples.
37
43
*
38
- * @example
39
- * ```tsx
40
- * // Send messages to all participants
41
- * const { message: latestMessage, send } = useDataChannel('chat', (msg) => console.log("message received", msg));
42
- * ```
43
44
* @public
44
45
*/
45
46
export function useDataChannel (
0 commit comments