useRequest
Fire a one-shot request on mount and re-fire each time source changes identity or refresh()
is called. Returns reactive state tracking the call's lifecycle.
Two ways to pass the work:
- A ReactiveActionSource — the
{ reactiveStore() }duck-type satisfied byPendingRpcRequest. - An async function
(signal: AbortSignal) => Promise<T>— wrap any one-shot async source (afetch, a third-party SDK call, etc). Most general shape.
Pass null to disable; the result reports status: 'disabled'.
Memoize the input (useMemo for a source, useCallback for a function) keyed on whatever
inputs it depends on.
Type Parameters
| Type Parameter | Description |
|---|---|
T | The value the underlying request resolves to. |
Parameters
| Parameter | Type |
|---|---|
source | | ReactiveActionSource<T> | ((signal) => Promise<T>) | null |
options? | UseRequestOptions |