Type Alias: CommandHandler<D, R>
ts
type CommandHandler<D, R> = (payload: D) => MaybePromise<R>;Defined in: src/wirestate-core/types/commands.ts:40
Represents the function that handles a command.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
D | unknown | Type of the input payload (data) for the command. |
R | unknown | Type of the result returned by the handler (can be wrapped in a Promise). |
Parameters
| Parameter | Type |
|---|---|
payload | D |
Returns
MaybePromise<R>
Example
typescript
const loginHandler: CommandHandler<Credentials, Session> = (payload) => {
return auth.login(payload);
};