-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Add methods Observer::with_entities and Observer::watch_entities #20274
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
base: main
Are you sure you want to change the base?
Conversation
It looks like your PR has been selected for a highlight in the next release blog post, but you didn't provide a release note. Please review the instructions for writing release notes, then expand or revise the content in the release notes directory to showcase your changes. |
Please add this PR to the ongoing "observer overhaul" path note. |
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.
This doesn't make anything new possible, but it does make it faster and cleaner. I'm alright with this :)
@@ -200,8 +200,7 @@ use crate::prelude::ReflectComponent; | |||
/// | |||
/// Note that the [`Observer`] component is not added to the entity it is observing. Observers should always be their own entities! | |||
/// | |||
/// You can call [`Observer::watch_entity`] more than once, which allows you to watch multiple entities with the same [`Observer`]. | |||
/// serves as the "source of truth" of the observer. |
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.
Removed this mangled comment from the previous documentation about ObserverState
. Or should it be updated instead ?
Objective
From time to time, I find myself observing multiple entities with the same
Observer
. Right now this can only be achieved by callingwith_entity
orwatch_entity
for each entity to watch. This PR provides versions of these two methods to watch multiple entities with a single call.Testing
Added a simple test.