mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-12-18 16:43:21 +00:00
26 lines
534 B
Rust
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}"
|
|
}
|
|
}
|