Skip to content

v2: Events DSL - Add event() function and update EventMetadata #749

Description

@javiertoledo

Parent

Part of #739

Context

Events currently use class-based metadata:

interface EventMetadata {
  readonly class: Class<EventInterface>
}

Events need to be migrated to the data-oriented pattern established by commands.

Proposed Changes

  1. Create event() DSL function in packages/core/src/dsl/event.ts
  2. Update EventMetadata to use name + entityID function instead of class reference
  3. Update event dispatching/handling to use new metadata
  4. Reimplement @Event decorator as thin wrapper around DSL
  5. Update reducers that reference events

Design Considerations

  • Events are simpler than commands (no authorization, no hooks)
  • Events have an entityID() method that links them to entities — this needs a clean DSL representation
  • Reducers reference events by name — ensure compatibility
  • Event handlers receive event instances — consider how DSL events work with handlers

Acceptance Criteria

  • event() DSL function created
  • EventMetadata updated to data-oriented format
  • @Event decorator reimplemented as wrapper
  • All existing tests pass
  • New tests for DSL event definition

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