dioxus/packages/signals/examples/send.rs
2024-01-30 17:59:57 -08:00

21 lines
396 B
Rust

use dioxus::prelude::*;
fn main() {
launch(app);
}
fn app() -> Element {
let mut signal = use_signal_sync(|| 0);
use_hook(|| {
std::thread::spawn(move || loop {
std::thread::sleep(std::time::Duration::from_secs(1));
signal += 1;
});
});
rsx! {
button { onclick: move |_| signal += 1, "Increase" }
"{signal}"
}
}