Add specific event helpers for `.on(EventName, handler)`
- Dominant language
- Rust
- Stars
- 38
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
**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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.