Skip to content

Function: useOptionalQueryExecutor()

ts
function useOptionalQueryExecutor(): OptionalQueryExecutor;

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

Returns a stable function to dispatch optional synchronous queries on the active container.

Returns

OptionalQueryExecutor

An optional 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. Use useOptionalAsyncQueryExecutor when consumers should consistently receive a Promise.

Example

tsx
const queryOptional: OptionalQueryExecutor = useOptionalQueryExecutor();
const settings: UserSettings | null = queryOptional(GET_USER_SETTINGS, { id: 1 });