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:
1 parent
ffb5c98449
commit
1dfa1b5e7f
9 files changed
+47
-26
No files matched your search
+2
-1
@@ -3,6 +3,7 @@
|
||||
//! Eval will only work with renderers that support javascript - so currently only the web and desktop/mobile renderers
|
||||
//! that use a webview. Native renderers will throw "unsupported" errors when calling `eval`.
|
||||
|
||||
use async_std::task::sleep;
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
@@ -13,7 +14,7 @@ fn app() -> Element {
|
||||
// Create a future that will resolve once the javascript has been successfully executed.
|
||||
let future = use_resource(move || async move {
|
||||
// Wait a little bit just to give the appearance of a loading screen
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
|
||||
sleep(std::time::Duration::from_secs(1)).await;
|
||||
|
||||
// The `eval` is available in the prelude - and simply takes a block of JS.
|
||||
// Dioxus' eval is interesting since it allows sending messages to and from the JS code using the `await dioxus.recv()`
|
||||
|
||||
Reference in new issue
Block a user