Interface: ChannelHooks<M>
A channel bound to a name and message map: typed hooks with no per-call generics.
Type Parameters
| Type Parameter |
|---|
M extends MessageMap |
Properties
get
get: () => Channel<M>;
The underlying channel instance (the same one the hooks use) — for non-React code.
Returns
Channel<M>
useMessage
useMessage: <K>(type, handler) => void;
Subscribe to one message type. Same contract as the standalone
useMessage: the handler is kept fresh without resubscribing.
Type Parameters
| Type Parameter |
|---|
K extends string |
Parameters
| Parameter | Type |
|---|---|
type | K |
handler | (payload, meta) => void |
Returns
void
useSend
useSend: () => <K>(type, payload) => void;
The channel's post function (stable identity).
Returns
<K>(type, payload): void;
Fire-and-forget to every other tab/window/worker on this origin. Not echoed to self.
Type Parameters
| Type Parameter |
|---|
K extends string |
Parameters
| Parameter | Type |
|---|---|
type | K |
payload | M[K] |
Returns
void