Channel
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
M extends MessageMap | - |
R extends ReplyMap<M> | Record<never, never> |
Properties
Section titled “Properties”clientId
Section titled “clientId”readonly clientId: string;readonly name: string;Methods
Section titled “Methods”answer()
Section titled “answer()”answer<K>(type, responder): () => void;Answer asks of this type. Returns an unsubscribe.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
K extends string |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
type | K |
responder | (payload, meta) => R[K] |
Returns
Section titled “Returns”() => void
ask<K>( type, payload,options?): Promise<R[K]>;Ask the origin a question and wait for the first answer.
Rejects if nobody answers before the timeout — an unanswered question is a
fact worth having rather than a promise that hangs. If several clients
registered an answer for this type, the first reply to arrive wins and
the rest are dropped; gate the responder on leadership when you need the
answer to come from a particular tab.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
K extends string |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
type | K |
payload | M[K] |
options? | AskOptions |
Returns
Section titled “Returns”Promise<R[K]>
close()
Section titled “close()”close(): void;Returns
Section titled “Returns”void
on<K>( type, handler, options?): () => void;Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
K extends string |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
type | K |
handler | (payload, meta) => void |
options? | OnOptions |
Returns
Section titled “Returns”() => void
post()
Section titled “post()”post<K>( type, payload, options?): void;Fire-and-forget to every other tab/window/worker on this origin.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
K extends string |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
type | K |
payload | M[K] |
options? | PostOptions |
Returns
Section titled “Returns”void