Skip to content

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 ParameterDefault typeDescription
DunknownType of the input payload (data) for the command.
RunknownType of the result returned by the handler (can be wrapped in a Promise).

Parameters

ParameterType
payloadD

Returns

MaybePromise<R>

Example

typescript
const loginHandler: CommandHandler<Credentials, Session> = (payload) => {
  return auth.login(payload);
};