Reactive UI framework for Bevy.
This crate provides a framework for UI and other reactive systems using the ECS.
Components can be created with lazy
and run in parallel like regular systems (they can even use Local
and other system parameters).
#[derive(Component, Deref, DerefMut)]
struct Count(i32);
fn app() -> impl Compose {
lazy(|mut count: UseState<Count>| {
let (count, count_entity) = count.use_state(|| Count(0));
flex((
format!("High five count: {}", **count),
flex("Up high!").on_click(move |mut count_query: Query<&mut Count>| {
if let Ok(mut count) = count_query.get_mut(count_entity) {
**count += 1
}
}),
flex("Down low!").on_click(move |mut count_query: Query<&mut Count>| {
if let Ok(mut count) = count_query.get_mut(count_entity) {
**count -= 1
}
}),
))
})
}
This crate is inspired by Xilem, Concoct and SwiftUI with its typed approach to reactivity.