useAsk
function useAsk<M, R>(channel): <K>(type, payload, options?) => Promise<R[K]>;The channel’s ask function (stable identity per channel).
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
M extends MessageMap |
R extends Partial<Record<keyof M, unknown>> |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
channel | Channel<M, R> |
Returns
Section titled “Returns”<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]>