Rxova
Skip to content

useAnswer

function useAnswer<M, R, K>(
channel,
type,
responder,
options?): void;

Answer asks of one type for as long as this component is mounted.

A hook rather than a bare channel.answer call because a responder is a subscription: registering one in a render would leave the last unmounted component answering for the page.

One responder per type per channel — registering a second replaces the first, which is the same first-wins-then-replace rule answer has in core.

Type Parameter
M extends MessageMap
R extends Partial<Record<keyof M, unknown>>
K extends string
ParameterType
channelChannel<M, R>
typeK
responder(payload, meta) => R[K]
options?{ enabled?: boolean; }
options.enabled?boolean

void