diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index 81d7baeb4b520..61bbad3aedbd6 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -1306,6 +1306,8 @@ impl App { /// Spawns an [`Observer`] entity, which will watch for and respond to the given event. /// + /// `observer` can be any system whose first parameter is a [`Trigger`]. + /// /// # Examples /// /// ```rust @@ -1326,7 +1328,7 @@ impl App { /// # #[derive(Component)] /// # struct Friend; /// # - /// // An observer system can be any system where the first parameter is a trigger + /// /// app.add_observer(|trigger: Trigger, friends: Query>, mut commands: Commands| { /// if trigger.event().friends_allowed { /// for friend in friends.iter() { diff --git a/crates/bevy_ecs/src/observer/mod.rs b/crates/bevy_ecs/src/observer/mod.rs index 2343e66aa1c85..767dc7ec95d37 100644 --- a/crates/bevy_ecs/src/observer/mod.rs +++ b/crates/bevy_ecs/src/observer/mod.rs @@ -536,6 +536,8 @@ impl World { /// Spawns a "global" [`Observer`] which will watch for the given event. /// Returns its [`Entity`] as a [`EntityWorldMut`]. /// + /// `system` can be any system whose first parameter is a [`Trigger`]. + /// /// **Calling [`observe`](EntityWorldMut::observe) on the returned /// [`EntityWorldMut`] will observe the observer itself, which you very /// likely do not want.** diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index 8b10b64b28ce2..d5e1b068fd4c5 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -1068,6 +1068,8 @@ impl<'w, 's> Commands<'w, 's> { /// Spawns an [`Observer`] and returns the [`EntityCommands`] associated /// with the entity that stores the observer. /// + /// `observer` can be any system whose first parameter is a [`Trigger`]. + /// /// **Calling [`observe`](EntityCommands::observe) on the returned /// [`EntityCommands`] will observe the observer itself, which you very /// likely do not want.** @@ -1075,6 +1077,8 @@ impl<'w, 's> Commands<'w, 's> { /// # Panics /// /// Panics if the given system is an exclusive system. + /// + /// [`Trigger`]: crate::observer::Trigger pub fn add_observer( &mut self, observer: impl IntoObserverSystem,