This commit is contained in:
2026-01-24 00:28:43 +01:00
parent 15ff801cb0
commit 0a026c4ee7
3 changed files with 16 additions and 42 deletions
+5 -14
View File
@@ -24,24 +24,13 @@ fn main() {
});
loop {
println!("{:?}", cx.get_nodes());
cx.get_view()(&mut DrawContext {});
std::thread::sleep(std::time::Duration::from_millis(16));
}
}
fn app(cx: &Arc<Context>) -> Vec<Node> {
fn app(cx: &Arc<Context>) -> View {
let count = use_state(0);
let count2 = use_state(0);
use_effect(
{
let count2 = count2.clone();
move || {
*count2.get() += 1;
}
},
&[&count],
);
cx.on_event({
let count = count.clone();
@@ -52,5 +41,7 @@ fn app(cx: &Arc<Context>) -> Vec<Node> {
}
});
vec![Node::String(Arc::new(move || format!("{count} {count2}")))]
Arc::new(move |_| {
println!("Count: {count}");
})
}