update interperter to use CapuredContext
This commit is contained in:
1 parent
871f51f91b
commit
62cca95905
5 files changed
+145
-48
No files matched your search
+12
-3
@@ -1,15 +1,24 @@
|
||||
use dioxus::prelude::*;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
dioxus::desktop::launch_with_props(with_hot_reload, app, |b| b);
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
let mut count = use_state(&cx, || 0);
|
||||
let count = use_state(&cx, || 0);
|
||||
|
||||
use_future(&cx, (), move |_| {
|
||||
let mut count = count.clone();
|
||||
async move {
|
||||
loop {
|
||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cx.render(rsx! {
|
||||
h1 { "High-Five counter: {count}" }
|
||||
button { onclick: move |_| count += 1, "Up high!" }
|
||||
button { onclick: move |_| count -= 1, "Down low!" }
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user