Add the ability for SubApps to have a custom update function #18189
+71
−21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Implement the solution proposed for #18185
Solution
Added a new field to SubApps,
update_fn
, which contains the function to invoke for runningSubApps::update()
.SubApps::update()
was preserved to allow invariant update behavior to be introduced in the future if necessary, and for ease of use. Broke out the Default implementation forSubApps
so that the update function is set by default.Testing
PR opened to run bevy test suite (my poor laptop would get mad), API fits the constraints I described in https://canary.discord.com/channels/691052431525675048/742569353878437978/1347321570603044999, full convo transcribed:
[15:35]moony (Kaylie!): atm the blocker seems to be making whatever i do work with the existing winit code
[15:37]moony (Kaylie!): (I'm already targetting latest instead of stable due to needing .sub_apps() so if it's specific to latest that's still good to know)
[16:26]moony (Kaylie!): i have worked out a scrungly solution for the meantime: App in my App.
[16:43]Alice 🌹: Not really, this is kinda half-baked still
[16:43]moony (Kaylie!): just being able to replace update() with my own func would be sufficient tbh and likely covers most uses
[16:44]moony (Kaylie!): filing an issue about that approach atm
[16:45]Alice 🌹: Okay sweet; that's appreciated. We haven't done a ton of digging into the exact ways that users might want to extend / modify this design, so experienced-based opinions are really useful
[16:45]Alice 🌹: Mostly my reaction to subapps and windowing is :pain2: due to the difficulty testing and all of the platforms, so changes there are really slow currently
[16:46]moony (Kaylie!): my exact constraint is I'm adding some arbitrary N set of scene subapps for worlds the player could be in, and allowing the user to swap between them
this is very easy to do if i can just control which subapp render is running extract on (and otherwise control the extract flow myself)
[16:46]moony (Kaylie!): in other words a single "main" subapp isn't the right approach for my experiment
[16:47]Alice 🌹: Interesting. What's the ultimate motivation for that? For the most part my opinion is "don't use subapps if at all possible", and I'd generally use something like states and scenes or something for that design
[16:47]moony (Kaylie!): isolating those scenes, because UGC
[16:48]moony (Kaylie!): if one scene gets completely mucked up for whatever reason the user should be able to just close or leave it and be fine
[16:48]Alice 🌹: Aha, interesting! Okay, that makes more sense to me