Event
trait should not be reused for observers and buffered events
#16031
Labels
A-ECS
Entities, components, systems, and events
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
S-Ready-For-Implementation
This issue is ready for an implementation PR. Go for it!
X-Controversial
There is active debate or serious implications around merging this PR
Milestone
What problem does this solve or what need does it fill?
While the
Event
trait is required for both observers and buffered events, it's very uncommon to use a single event type as both an observer and a buffered event.These are used differently and have distinct semantics, despite both representing .
This makes the API more challenging to understand, opens users up to footguns where they create
EventReader
s for observer events or send buffered events via targeting, and also causes false positives for potential linting tools that attempt to check for things like "allEvent
types should have aadd_event
call".What solution would you like?
Split the trait, keeping the
Event
trait name for buffered events, andSignal
for observer events.What alternative(s) have you considered?
We could consider unifying the underlying implementations in some way, to allow for users to seamlessly choose between them. That would entail:
I don't think that this is particularly useful or clear, and has a non-trivial performance overhead. Given that I haven't seen users asking for this, and it can be easily manually implemented if it is desired, I don't think this is the right call.
Additional context
I advocated for adding a marker trait for observer events here. Much bikeshedding followed.
The unification was eventually completed by @cart in #10839 (comment), per #10839 (comment).
IMO this change didn't get appropriate consideration due to the extreme length and complexity of that PR and should be reverted :)
The text was updated successfully, but these errors were encountered: