-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 a variant of Events::update
that returns the removed events
#9542
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like a bit of reassurance that this compiles down to the same code as a naive "duplicate the code" solution, but I won't block on it.
A doc test would be good too.
Calling I will add a test or two. |
@JoJoJet this needs to have merge conflicts resolved, then I'll merge :) |
…vyengine#9542) # Objective Every frame, `Events::update` gets called, which clears out any old events from the buffer. There should be a way of taking ownership of these old events instead of throwing them away. My use-case is dumping old events into a debug menu so they can be inspected later. One potential workaround is to just have a system that clones any incoming events and stores them in a list -- however, this requires the events to implement `Clone`. ## Solution Add `Events::update_drain`, which returns an iterator of the events that were removed from the buffer.
Objective
Every frame,
Events::update
gets called, which clears out any old events from the buffer. There should be a way of taking ownership of these old events instead of throwing them away. My use-case is dumping old events into a debug menu so they can be inspected later.One potential workaround is to just have a system that clones any incoming events and stores them in a list -- however, this requires the events to implement
Clone
.Solution
Add
Events::update_drain
, which returns an iterator of the events that were removed from the buffer.