bevy_spawn_observer

Crates.iobevy_spawn_observer
lib.rsbevy_spawn_observer
version0.1.1
created_at2025-04-23 11:11:06.579191+00
updated_at2025-08-13 18:27:17.708605+00
descriptionAdd observers to your bundles
homepage
repositoryhttps://github.com/benfrankel/bevy_spawn_observer
max_upload_size
id1645386
size129,856
Ben Frankel (benfrankel)

documentation

README

bevy_spawn_observer

Crates.io Docs License

This crate provides SpawnObserver, a custom SpawnableList enabling you to add observers to your bundles.

use bevy::{ecs::spawn::SpawnWith, prelude::*};
use bevy_spawn_observer::SpawnObserver;

// With `bevy_spawn_observer`:
fn button_new() -> impl Bundle {
    (
        Button,
        Children::spawn(SpawnObserver::new(|_: Trigger<Pointer<Click>>| {
            info!("You clicked me!");
        })),
    )
}

// Without `bevy_spawn_observer`:
fn button_old() -> impl Bundle {
    (
        Node::default(),
        Children::spawn(SpawnWith(|parent: &mut ChildSpawner| {
            parent.spawn(Button).observe(|_: Trigger<Pointer<Click>>| {
                info!("You clicked me!");
            });
        })),
    )
}

See a full example here.

Bevy version compatibility

bevy version bevy_spawn_observer version
0.16 0.1

License

This crate is available under either of MIT or Apache-2.0 at your choice.

Commit count: 14

cargo fmt