-
-
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 RunSystem
#9366
Add RunSystem
#9366
Conversation
Add a `RunSystem` extension trait to allow for immediate execution of systems on a `World` for debugging and/or testing purposes.
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.
Looks like a neat helper for tests.
Co-authored-by: Pascal Hertleif <killercup@gmail.com>
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 like this api much better than the previous pr.
Not a huge fan of implementing on &mut App just for decreased verbosity. A little worse ergonomics for tests is fine and we're polluting the public api. But not worth blocking on.
I was debating that myself. Especially because compared to the previous PR, with this one you don't really need the app anymore to test systems, and in the few cases where we do want the app, using So I think you're right. I'll remove the implementation for |
Remove `RunSystem` impl for `&mut App`
Add a
RunSystem
extension trait to allow for immediate execution of systems on aWorld
for debugging and/or testing purposes.Objective
Fixes #6184
Initially, I made this CL as
ApplyCommands
. After a discussion with @cart , we decided a more generic implementation would be better to support all systems. This is the new revised CL. Sorry for the long delay! 😅This CL allows users to do this:
Solution
This is implemented as a trait extension and not included in any preludes to ensure it's being used consciously.
Internally, it just initializes and runs a systems, and applies any deferred parameters all "in place".
The trait has 2 functions (one of which calls the other by default):
run_system_with
is the general implementation, which allows user to pass system input parametersrun_system
is the ergonomic wrapper for systems with no input parameter (to avoid having the user pass()
as input).Additionally, this trait is also implemented for(Removed based on feedback)&mut App
. I added this mainly for ergonomics (app.run_system
vs.app.world.run_system
).