Skip to content

v2: Event Handlers DSL #751

Description

@javiertoledo

Parent

Part of #739

Context

Event handlers currently use a class-based interface:

interface EventHandlerInterface {
  handle(event: EventInterface | NotificationInterface, register: Register): Promise<void>
}

And are stored as class instances in config:

eventHandlers: Record<EventName, Array<EventHandlerInterface>>

Proposed Changes

  1. Create eventHandler() DSL function in packages/core/src/dsl/event-handler.ts
  2. Update EventHandlerMetadata to use handler functions
  3. Update event dispatching to call handler functions directly
  4. Reimplement @EventHandler decorator as wrapper

Design Considerations

  • Event handlers are linked to specific event types
  • Multiple handlers can react to the same event
  • Handlers receive a Register to emit further events (event chaining)
  • The interface currently stores instances, not classes — the migration is straightforward

Acceptance Criteria

  • eventHandler() DSL function created
  • Metadata updated to function-based format
  • Decorator reimplemented as wrapper
  • All existing tests pass
  • New tests for DSL definitions

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions