fix: use futuresunordered instead of bespoke waker system

This commit is contained in:
Jonathan Kelley committed 2022-12-29 19:53:43 -05:00
1 parent ff697d41e3
commit bd720e2268
12 files changed
+308 -272

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
//! Example: README.md showcase
//!
//! The example from the README.md.
use dioxus::prelude::*;
use futures_util::Future;
#[tokio::main]
async fn main() {
let mut dom = VirtualDom::new(app);
dom.rebuild();
loop {
dom.wait_for_work().await;
}
// dioxus_desktop::launch(app).await;
}
fn app(cx: Scope) -> Element {
let mut count = use_ref(cx, || 0);
let mut ct = count.to_owned();
use_coroutine(cx, |_: UnboundedReceiver<()>| async move {
loop {
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
*ct.write() += 1;
let current = *ct.read();
println!("current: {}", current);
}
});
let mut count = count.read();
cx.render(rsx! {
div { "High-Five counter: {count}" }
})
}
+3 -2
View File
@@ -3,8 +3,9 @@
use dioxus::prelude::*;
use dioxus_elements::input_data::keyboard_types::Key;
fn main() {
dioxus_desktop::launch(app);
#[tokio::main]
async fn main() {
dioxus_desktop::launch(app).await;
}
#[derive(PartialEq, Eq)]