Skip to content

Add specific event helpers for .on(EventName, handler) #48

@dclause

Description

@dclause

Motivation
Today, any struct that needs to handle events declares an EventManager attribute and a generic .on() method that simply delegates to the event manager’s registration function. However, this generic approach requires passing the event name as a first argument every time, which can be cumbersome and less ergonomic for users.

Expectation
The purpose of this task is to define a macro that uses the event enum to automatically:

  • declares the public event enum along with its documentation
  • generates a generic .on() method for the associated class
  • generates specific alias methods like .on_eventname(...) for each event variant, avoiding the need to explicitly pass the event each time
  • updates all examples and code samples to use the convenience alias methods rather than the generic version

API change:
There is no breaking change for library users, since the generic .on() method remains available for advanced use cases. However, examples and documentation should be updated to prefer the new convenience methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    code qualityIssue is related to refactoring or improving code quality overall.feature requestNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions