aevyrie / bevy_eventlistener

Event listening, bubbling, and callbacks
Apache License 2.0
178 stars 27 forks source link

Event sinking #28

Open marstaik opened 6 months ago

marstaik commented 6 months ago

We currently can traverse up the hierarchy via bubbles, which is great! I think we can extend this by also allowing for sinking - letting an Event propagate down the tree from the calling node.

While this may prove worse in terms of performance (linearly going up the tree vs recursively going down children) for most situations, there are times when having a parent node and propagating events generated on the parent to all the children is a good design choice.

This feature would work like another trait on EntityEvents, : #[can_sink]

This would not block #[can_bubble], and if you define both then your event gets sent both up and down the tree.