Skip to content

Type Alias: QueryHandler<D, R>

ts
type QueryHandler<D, R> = (data: D) => MaybePromise<R>;

Defined in: src/wirestate-core/types/queries.ts:36

Represents the function that handles a query.

Type Parameters

Type ParameterDefault typeDescription
DunknownType of the input data (payload).
RunknownType of the returned result.

Parameters

ParameterType
dataD

Returns

MaybePromise<R>

Remarks

Query handlers can be synchronous or asynchronous. They receive a payload and must return a result (or a Promise resolving to it).

Example

typescript
const handler: QueryHandler<string, User> = (userId) => userRepository.find(userId);