Use of async_std::task::sleep instead of tokio::time::sleep in examples (#2912)

* Use of async_std::task::sleep instead of tokio::time::sleep

* Make the clock example run on wasm

* Add control_focus and eval examples to Cargo.toml

* Use web-time on desktop; It just falls back to std on non-wasm platforms

---------

Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
This commit is contained in:
ASR-ASUandEvan Almloff authored and GitHub committed 2024-09-03 15:16:37 +00:00
1 parent ffb5c98449
commit 1dfa1b5e7f
9 files changed
+47 -26

No files matched your search

+3 -3
View File
@@ -6,8 +6,8 @@
//! Most signals implement Into<ReadOnlySignal<T>>, making ReadOnlySignal a good default type when building new
//! library components that don't need to modify their values.
use async_std::task::sleep;
use dioxus::prelude::*;
use std::time::Duration;
fn main() {
launch(app);
@@ -39,13 +39,13 @@ fn app() -> Element {
if running() {
count += 1;
}
tokio::time::sleep(Duration::from_millis(400)).await;
sleep(std::time::Duration::from_millis(400)).await;
}
});
// use_resource will spawn a future that resolves to a value
let _slow_count = use_resource(move || async move {
tokio::time::sleep(Duration::from_millis(200)).await;
sleep(std::time::Duration::from_millis(200)).await;
count() * 2
});