-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Exit schedule for systems to run at end of app run #7355
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
Conversation
I really want this, but you're going to need to wait until #7267 is merged, and then use the |
I really don't want this, or you need to put heavy disclaimers that there are no guarantees any code in this schedule will run |
Didn't know you could see draft pull requests ^-^' This is my first PR on a scale more than a small bugfix. Yeah, I realized pretty early into implementation that this would touch stageless stuff, and tried to write it in a way I figured would be easy to rework without stages, and didn't add more than a single stage to the ExitSchedule. But it sounds like the schedule changes are deeper than I thought, so I'm fine waiting until stageless is merged. As far as whether this should exist or not, I feel like that's a conversation above my paygrade here. I tried my best to be transparent in the documentation, and I'm fine adding a disclaimer about there being no guarantees for exit systems to run. For the documention, situations that would probably not run exit systems would be:
|
No worries!
There aren't that much paygrades around, and your opinion matters and is valued.
That comes to mind:
|
Awwww, warm fuzzies! Merci mon pote! Okay, that makes sense. Of course if the user cuts power no exit schedule would run. The iOs/Android comment brings an idea to mind. From the one time I tried mobile development, I vaguely remember that there were hooks that give some time to run code before an app is closed. Is there a way to take advantage of these hooks in current bevy? Here's my summary of general pros and cons of this: Pros:
Cons
Perhaps a good way to get the best of both sides would be to create the specific exit schedule, add handling for it in runners, but we don't add an API specifically for exit systems to main We can instead create a trait Those are my ideas on this anyways! |
We should disable this feature on the platforms this doesn't work on. Probably wrap it all in a feature flag. |
|
Closing this as the cons outweigh the pros and there hasn't been much interest in this for almost a year |
Objective
Adding a structure for systems that run only when the App is closing.
Fixes #7067
Solution
Adds a Schedule to the default stages with label
ExitSchedule
to run systems at the end of the App.Changelog
Added
ExitSchedule
struct as label for new exit schedule.ExitStage
struct as label for new exit schedule's only stage, since it seems schedules need at least one stage currently. I presume this will be easy enough to remove after the stageless RFC.AppExit
documentation to mention exit systems.add_exit_system
andadd_exit_system_set
APIs toApp
to add systems to the exit schedule.teardown
API to App so that runners can call the exit schedule.Changed
App::teardown
before exiting.App::teardown
before exiting.App::add_default_stages()
method.Migration Guide
App::teardown
in order to run exit systems.