2023-11-07 19:15:19 +00:00
|
|
|
use dioxus::prelude::*;
|
|
|
|
use dioxus_signals::*;
|
|
|
|
|
|
|
|
fn main() {
|
2024-01-19 22:19:49 +00:00
|
|
|
// dioxus_desktop::launch(App);
|
2023-11-07 19:15:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[component]
|
2024-01-19 22:19:49 +00:00
|
|
|
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;
|
2024-01-19 22:19:49 +00:00
|
|
|
});
|
2023-11-07 19:15:19 +00:00
|
|
|
});
|
|
|
|
|
2024-01-19 22:19:49 +00:00
|
|
|
rsx! {
|
|
|
|
button { onclick: move |_| signal += 1, "Increase" }
|
2023-11-07 19:15:19 +00:00
|
|
|
"{signal}"
|
|
|
|
}
|
|
|
|
}
|