chore: more signals methods

This commit is contained in:
Jonathan Kelley committed 2023-01-01 22:02:49 -05:00
1 parent 4f9d67fb45
commit c0315e55f4
3 files changed
+48 -23

No files matched your search

+1 -12
View File
@@ -14,28 +14,17 @@ fn app(cx: Scope) -> Element {
use_init_signal_rt(cx);
let mut count = use_signal(cx, || 0);
let mut running = use_signal(cx, || false);
use_coroutine(cx, |_: UnboundedReceiver<()>| async move {
loop {
if running.get() {
count += 1;
}
count += 1;
tokio::time::sleep(Duration::from_millis(100)).await;
}
});
cx.render(rsx! {
h1 { "High-Five counter: {count}" }
button { onclick: move |_| count += 1, "Up high!" }
button { onclick: move |_| count -= 1, "Down low!" }
button { onclick: move |_| running.set(!running.get()), "Start counting" }
if count.get() > 3 {
rsx! ( h2 { "Nice!" } )
}
})
}