bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Added peeking to EventReader

Open BobG1983 opened this issue 1 year ago • 9 comments

Added peekability to EventReader for when you want to view an event but not mark it as read

Objective

  • Allow the ability to view an event without marking it as read

Solution

  • Copied the existing iterators and implemented them for peeking, ie. they no longer move the "last_read" onwards.
  • I also took this opportunity to improve the documentation on EventReader given I was adding explanations for peeking.

Testing

  • Wrote a number of tests to confirm that the new peek iterators work as expected. Renamed a bunch of the existing tests to specify they test read and wrote peek equivalents. Also wrote tests for combination of reading and peeking to make sure behavior was as expected.

BobG1983 avatar Jun 11 '24 18:06 BobG1983

No idea why the MacOS build fails given I didn't touch those files at all?

BobG1983 avatar Jun 11 '24 19:06 BobG1983

The issue is that par_read doesn't mark events as seen like read which I assumed it did, I ended up rewriting the tests to validate that behavior. Which par_read then failed.

It looks like this has always been the behavior of par_read

BobG1983 avatar Jun 11 '24 23:06 BobG1983

Added the fix from #13836 to this pull request too given I'm going to squash the files and tests associated with it.

BobG1983 avatar Jun 13 '24 21:06 BobG1983

I'm marking this as blocked by #13836. Once that gets merged and this gets enough reviews, this can be merged :)

BD103 avatar Jun 15 '24 18:06 BD103

@BD103 I wouldn’t say this is blocked. In fact. This has the fix in it already so if this is merged the other PR doesn’t need to be.

BobG1983 avatar Jun 17 '24 18:06 BobG1983

Failed because of a formatting requirement that I can’t really fix on my phone. Will take a look tomorrow.

BobG1983 avatar Jun 17 '24 18:06 BobG1983

@BD103 I wouldn’t say this is blocked. In fact. This has the fix in it already so if this is merged the other PR doesn’t need to be.

I would prefer we split it up into two different PRs, but I'll defer to maintainers on this. :)

BD103 avatar Jun 18 '24 15:06 BD103

Only reason I included it in here is because I squash the existing iterator file anyway.

BobG1983 avatar Jun 18 '24 16:06 BobG1983

This branch is now stacked on top of https://github.com/bevyengine/bevy/pull/13818

BobG1983 avatar Jun 24 '24 17:06 BobG1983

Completed in https://github.com/bevyengine/bevy/pull/13818

alice-i-cecile avatar Jul 14 '24 19:07 alice-i-cecile