Skip to content

Function: useOptionalAsyncQueryExecutor()

ts
function useOptionalAsyncQueryExecutor(): OptionalAsyncQueryExecutor;

Defined in: src/wirestate-react/queries/use-optional-async-query-executor.ts:28

Returns a stable function to dispatch optional async-capable queries on the active container.

Returns

OptionalAsyncQueryExecutor

An optional async query executor function.

Remarks

The returned executor is memoized using useCallback and stays stable for the lifetime of the container. It returns null instead of throwing if no handler is registered and uses QueryBus.queryOptionalAsync internally.

Example

tsx
const queryOptionalAsync: OptionalAsyncQueryExecutor = useOptionalAsyncQueryExecutor();
const settings: UserSettings | null = await queryOptionalAsync(GET_USER_SETTINGS, { id: 1 });