-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Added App::with_component_hooks #16977
Open
pin3-free
wants to merge
11
commits into
bevyengine:main
Choose a base branch
from
pin3-free:app-register-component-hooks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Added App::with_component_hooks #16977
pin3-free
wants to merge
11
commits into
bevyengine:main
from
pin3-free:app-register-component-hooks
+133
−1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixed CI failing because of unnecessary return type
You added a new example but didn't add metadata for it. Please update the root Cargo.toml file. |
…3-free/bevy into app-register-component-hooks
The generated |
…3-free/bevy into app-register-component-hooks
alice-i-cecile
added
A-ECS
Entities, components, systems, and events
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
S-Needs-Review
Needs reviewer attention (from anyone!) to move forward
labels
Dec 26, 2024
BenjaminBrienen
approved these changes
Dec 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-ECS
Entities, components, systems, and events
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
S-Needs-Review
Needs reviewer attention (from anyone!) to move forward
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
app.world_mut().register_component_hooks()
, which is somewhat clunky. This PR aims to introduce a more concise way to add component hooks directly from the app interfaceSolution
on_add
,on_insert
, etc.) they want to add the hook to. Plus there's the issue of fallible hook add methods.with_children
on theEntityCommands
, passing a closure that will mutate the target (in this case --&mut ComponentHooks
) and return the parent, allowing it to chain nicely into the multitude of calls usually associated withApp
.Testing
with_component_hooks.rs
in theecs
section of examples. It works identically to thecomponent_hooks
example, but uses the new APIShowcase
While a showcase should aim to be brief and digestible, you can use a toggleable section to save space on longer showcases: