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
@@ -1,11 +1,11 @@
//! Handle async streams using use_future and awaiting the next value.
use async_std::task::sleep;
use dioxus::prelude::*;
use futures_util::{future, stream, Stream, StreamExt};
use std::time::Duration;
fn main() {
launch_desktop(app);
launch(app);
}
fn app() -> Element {
@@ -30,7 +30,7 @@ fn app() -> Element {
fn some_stream() -> std::pin::Pin<Box<dyn Stream<Item = i32>>> {
Box::pin(
stream::once(future::ready(0)).chain(stream::iter(1..).then(|second| async move {
tokio::time::sleep(Duration::from_secs(1)).await;
sleep(std::time::Duration::from_secs(1)).await;
second
})),
)