Skip to content

onEvent

onEvent<TSchema>(contract, handler, options?): EventHandlerDeclaration

Defined in: packages/hoppity/src/handlers/onEvent.ts:16

Declares a typed event handler for use in the service config handlers array.

The handler’s content parameter type is inferred from the contract’s schema, so passing a handler whose content type doesn’t match the event schema is a compile-time error rather than a runtime surprise.

TSchema extends ZodTypeAny

EventContract<any, any, TSchema>

The EventContract to handle

EventHandler<TSchema>

The handler function

HandlerOptions

Optional queue/redelivery/dead-letter overrides

EventHandlerDeclaration