dioxus/packages/signals/examples/send.rs

24 lines
452 B
Rust
Raw Normal View History

2023-11-07 19:15:19 +00:00
use dioxus::prelude::*;
use dioxus_signals::*;
fn main() {
2024-01-20 00:36:40 +00:00
// dioxus::desktop::launch(App);
2023-11-07 19:15:19 +00:00
}
#[component]
fn App() -> Element {
let mut signal = use_signal_sync(|| 0);
use_hook(|| {
2023-11-07 19:15:19 +00:00
std::thread::spawn(move || loop {
std::thread::sleep(std::time::Duration::from_secs(1));
signal += 1;
});
2023-11-07 19:15:19 +00:00
});
rsx! {
button { onclick: move |_| signal += 1, "Increase" }
2023-11-07 19:15:19 +00:00
"{signal}"
}
}