Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to have multiple callbacks in a single listener #21

Open
alice-i-cecile opened this issue Mar 6, 2024 · 3 comments · May be fixed by #22
Open

Add the ability to have multiple callbacks in a single listener #21

alice-i-cecile opened this issue Mar 6, 2024 · 3 comments · May be fixed by #22

Comments

@alice-i-cecile
Copy link

This feature is necessary because there's currently no way to have more than one of a callback of a single type on an entity.

This is usually just a papercut, but it is required in bevy_mod_picking, in order to merge on_click / on_drag etc into a single callback.

In turn, we want to do that in order to handle the ordering of input events correctly„ using bevyengine/bevy#12100

@alice-i-cecile
Copy link
Author

This was discussed with @viridia on Discord: check that conversation for more details and design ideas.

@av1roytman
Copy link

Me and Xavier will try and tackle this

@aevyrie
Copy link
Owner

aevyrie commented Mar 6, 2024

I had a discussion on discord about the design of what this would look like: https://discord.com/channels/691052431525675048/1038322714320052304/1209594439832567818

The goal is that when you register a callback, you get a handle to that callback, so you can remove or replace it later.

impl<E: EntityEvent> On<E> {
    fn remove<E>(&mut self, handle: ListenerHandle<E>):
    fn replace<E>(&mut self, handle: ListenerHandle<E>, callback: tbd) 
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants