dioxus/packages/signals/examples/send.rs
Evan Almloff b3c5158524 fix tests
2023-11-07 13:15:19 -06:00

26 lines
534 B
Rust

use dioxus::prelude::*;
use dioxus_signals::*;
fn main() {
tracing_subscriber::fmt::init();
dioxus_desktop::launch(App);
}
#[component]
fn App(cx: Scope) -> Element {
let mut signal = use_signal_sync(cx, || 0);
cx.use_hook(|| {
std::thread::spawn(move || loop {
std::thread::sleep(std::time::Duration::from_secs(1));
signal += 1;
})
});
render! {
button {
onclick: move |_| signal += 1,
"Increase"
}
"{signal}"
}
}