#bevy #actuate #mod #compose #world #composable #command

bevy_mod_actuate

A reactive user-interface framework

9 unstable releases (3 breaking)

0.4.1 Nov 24, 2024
0.4.0 Nov 24, 2024
0.3.2 Nov 21, 2024
0.2.0 Nov 19, 2024
0.1.3 Nov 19, 2024

#2010 in Game dev

Download history 854/week @ 2024-11-18 98/week @ 2024-11-25 5/week @ 2024-12-09

957 downloads per month

MIT/Apache

47KB
375 lines

bevy_mod_actuate

Crates.io version docs.rs docs CI status

Declarative scenes and reactivity for Bevy powered by Actuate.

use actuate::prelude::{*, Mut};
use bevy::prelude::*;
use bevy_mod_actuate::prelude::*;

// Timer composable.
#[derive(Data)]
struct Timer;

impl Compose for Timer {
    fn compose(cx: Scope<Self>) -> impl Compose {
        let current_time = use_mut(&cx, Time::default);

        // Use the `Time` resource from the ECS world, updating the `current_time`.
        use_world(&cx, move |time: Res<Time>| Mut::set(current_time, *time));

        // Spawn a `Text` component, updating it when this scope is re-composed.
        spawn(Text::new(format!("Elapsed: {:?}", current_time.elapsed())))
    }
}

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, ActuatePlugin))
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2d::default());

    // Spawn a composition with a `Timer`, adding it to the Actuate runtime.
    commands.spawn(Composition::new(Timer));
}

Dependencies

~25–37MB
~596K SLoC