Handlers are where your application logic lives.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Indroic/HexCore/llms.txt
Use this file to discover all available pages before exploring further.
AbstractCommandHandler processes a single type of Command and optionally returns a result; AbstractQueryHandler reads data and returns a typed result without causing side effects. Both are abstract, generic classes — you parameterise them with the concrete message type and expected return type, and the type system guarantees your handle method matches the bus’s expectations.
AbstractCommandHandler
Type parameters
The specific
Command subclass this handler processes. Must be bound to Command.The return type of
handle(). Use None for fire-and-forget commands that produce no result.Abstract method
handle
The command instance dispatched by the bus. Guaranteed to be of the handler’s declared
TCommand type.The result of executing the command. Returns
None for fire-and-forget commands.AbstractQueryHandler
Type parameters
The specific
Query subclass this handler processes. Must be bound to Query[Any].The type of data returned by
handle(). Should match the TResult generic parameter on the corresponding Query subclass.Abstract method
handle
The query instance dispatched by the bus.
The query result — a DTO, a list, a primitive value, or any other type declared by
TResult.Backward-compatibility aliases
Abstract* counterparts. Existing code that imports ICommandHandler or IQueryHandler continues to work without modification.
Usage examples
A handler class must be registered with a
HandlerRegistry before the bus can resolve and invoke it. See the HandlerRegistry reference for registration patterns.