From 66bb90204adc6bcaefbfcc6e2520d378386eb786 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Wed, 8 Apr 2026 16:45:15 -0700 Subject: [PATCH 1/4] Add deprecation notice to observe helper function --- crates/bevy_ui_widgets/src/observe.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ui_widgets/src/observe.rs b/crates/bevy_ui_widgets/src/observe.rs index 944d0c198dd21..cbeef48df39e8 100644 --- a/crates/bevy_ui_widgets/src/observe.rs +++ b/crates/bevy_ui_widgets/src/observe.rs @@ -1,6 +1,8 @@ -// TODO: This probably doesn't belong in bevy_ui_widgets, but I am not sure where it should go. -// It is certainly a useful thing to have. #![expect(unsafe_code, reason = "Unsafe code is used to improve performance.")] +#![expect( + deprecated, + reason = "We need to use the pre-existing tools until this is removed." +)] use core::{marker::PhantomData, mem}; @@ -11,6 +13,10 @@ use bevy_ecs::{ }; /// Helper struct that adds an observer when inserted as a [`Bundle`]. +#[deprecated( + since = "0.19.0", + note = "Use the `on` helper with bsn! instead to spawn observers as part of ECS hierarchies." +)] pub struct AddObserver> { observer: I, marker: PhantomData<(E, B, M)>, @@ -74,6 +80,10 @@ impl> DynamicBundle } /// Adds an observer as a bundle effect. +#[deprecated( + since = "0.19.0", + note = "Use the `on` helper with bsn! instead to spawn observers as part of ECS hierarchies." +)] pub fn observe>( observer: I, ) -> AddObserver { From 83790d6520acf226b858de94dfd534bf18176155 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Wed, 8 Apr 2026 16:50:10 -0700 Subject: [PATCH 2/4] Write migration guide --- .../observe_bundle_helper_deprecation.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 _release-content/migration-guides/observe_bundle_helper_deprecation.md diff --git a/_release-content/migration-guides/observe_bundle_helper_deprecation.md b/_release-content/migration-guides/observe_bundle_helper_deprecation.md new file mode 100644 index 0000000000000..0be9f2fe8e0e2 --- /dev/null +++ b/_release-content/migration-guides/observe_bundle_helper_deprecation.md @@ -0,0 +1,34 @@ +--- +title: "`bevy_ui_widgets::observe` has been deprecated in favor of `bsn!`" +pull_requests: [TODO] +--- + +The `observe` function and `AddObserver` struct in `bevy_ui_widgets` have been deprecated. +These were a workaround for attaching observers as bundle effects. +Now that `bsn!` supports the `on` helper natively, use that instead. + +Before: + +```rust +use bevy_ui_widgets::observe; + +commands.spawn(( + Button, + observe(|_event: On>| { + println!("Clicked!"); + }), +)); +``` + +After: + +```rust +commands.spawn(bsn! { + Button + on(|_event: On>| { + println!("Clicked!"); + }) +}); +``` + +If you were using `AddObserver` directly for some reason, replace it with `on` inside a `bsn!` block in the same way. From 8c35f83b7d6f744a51efcbec6f3deeb02c58d242 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Wed, 8 Apr 2026 16:52:58 -0700 Subject: [PATCH 3/4] Note that deprecated virtual_keyboard_bundle uses observe as well --- crates/bevy_feathers/src/controls/virtual_keyboard.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_feathers/src/controls/virtual_keyboard.rs b/crates/bevy_feathers/src/controls/virtual_keyboard.rs index 3d87a3c99fd00..9ddc93b03cca1 100644 --- a/crates/bevy_feathers/src/controls/virtual_keyboard.rs +++ b/crates/bevy_feathers/src/controls/virtual_keyboard.rs @@ -81,7 +81,7 @@ where /// /// These events can be disabled by adding an [`bevy_ui::InteractionDisabled`] component to the entity #[deprecated(since = "0.19.0", note = "Use the virtual_keyboard() BSN function")] -#[expect(deprecated, reason = "uses the deprecated button_bundle")] +#[expect(deprecated, reason = "uses the deprecated button_bundle and observe")] pub fn virtual_keyboard_bundle( keys: impl Iterator> + Send + Sync + 'static, ) -> impl Bundle From f93188a18cb760786de68c75ff9eb9c281f9c8f7 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Wed, 8 Apr 2026 20:56:08 -0400 Subject: [PATCH 4/4] Update PR number --- .../migration-guides/observe_bundle_helper_deprecation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_release-content/migration-guides/observe_bundle_helper_deprecation.md b/_release-content/migration-guides/observe_bundle_helper_deprecation.md index 0be9f2fe8e0e2..2de24e47959ac 100644 --- a/_release-content/migration-guides/observe_bundle_helper_deprecation.md +++ b/_release-content/migration-guides/observe_bundle_helper_deprecation.md @@ -1,6 +1,6 @@ --- title: "`bevy_ui_widgets::observe` has been deprecated in favor of `bsn!`" -pull_requests: [TODO] +pull_requests: [23730] --- The `observe` function and `AddObserver` struct in `bevy_ui_widgets` have been deprecated.