Rxova
Skip to content

useAsk

function useAsk<M, R>(channel): <K>(type, payload, options?) => Promise<R[K]>;

The channel’s ask function (stable identity per channel).

Type Parameter
M extends MessageMap
R extends Partial<Record<keyof M, unknown>>
ParameterType
channelChannel<M, R>
<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 Parameter
K extends string
ParameterType
typeK
payloadM[K]
options?AskOptions

Promise<R[K]>