Skip to content

Conversation

@jaminhaber
Copy link

Objective

The observe() helper in bevy_ui_widgets is extremely useful in a bunch of contexts beyond just UI. I've ended up copying the original file from bevy_ui_widgets into multiple projects to get this functionality without adding the whole feature.

Solution

Move the helper out of bevy_ui_widgets and into bevy_ecs

Testing

Moving code without changes


Showcase

EX: Adding colliders to a GLTF scene
commands.spawn((
    SceneRoot(gltf_scene_handle),
    RigidBody::Static,
    observe(add_colliders)
))


fn add_colliders(
    trigger: On<SceneInstanceReady>,
    children: Query<&Children>,
    mut commands: Commands,
) {
...
}

@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change C-Usability A targeted quality-of-life change that makes Bevy easier to use X-Controversial There is active debate or serious implications around merging this PR S-Needs-SME Decision or review from an SME is required labels Dec 18, 2025
@alice-i-cecile
Copy link
Member

This was deliberately squirrelled away because it's a bit scuffed and unidiomatic.

I agree that it's extremely useful, and I want a real solution here, but I want to be sure we act carefully before fully letting that genie out on the bottle.

@jaminhaber jaminhaber force-pushed the move-observe-helper-to-ecs-observer-module branch from 384feec to 148c904 Compare December 18, 2025 20:49
@jaminhaber
Copy link
Author

@alice-i-cecile Ah I see, makes sense. Were you thinking of something like the children! macro, but for observers?

@alice-i-cecile
Copy link
Member

We're not entirely sure of the final shape. I believe @cart might have some plans here with respect to BSN, but I'd also like to be able to define observers directly via relations per #17607 to unify the whole thing.

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-Code-Quality A section of code that is hard to understand or change C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Needs-SME Decision or review from an SME is required X-Controversial There is active debate or serious implications around merging this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants