diff --git a/Cargo.lock b/Cargo.lock index 59cbf241a..133b5dc19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -83,15 +83,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - [[package]] name = "aho-corasick" version = "1.1.2" @@ -2461,7 +2452,6 @@ dependencies = [ "futures-util", "global-hotkey", "infer 0.11.0", - "minify-js", "muda", "objc", "objc_id", @@ -2653,7 +2643,6 @@ dependencies = [ "dioxus-interpreter-js", "futures-channel", "futures-util", - "minify-js", "once_cell", "pretty_env_logger", "rocket", @@ -4123,7 +4112,7 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ - "aho-corasick 1.1.2", + "aho-corasick", "bstr 1.9.0", "log", "regex-automata 0.4.3", @@ -4462,7 +4451,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ "ahash 0.8.7", - "bumpalo", ] [[package]] @@ -5960,16 +5948,6 @@ dependencies = [ "unicase", ] -[[package]] -name = "minify-js" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22d6c512a82abddbbc13b70609cb2beff01be2c7afff534d6e5e1c85e438fc8b" -dependencies = [ - "lazy_static", - "parse-js", -] - [[package]] name = "minimal-lexical" version = "0.2.1" @@ -6699,19 +6677,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "parse-js" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ec3b11d443640ec35165ee8f6f0559f1c6f41878d70330fe9187012b5935f02" -dependencies = [ - "aho-corasick 0.7.20", - "bumpalo", - "hashbrown 0.13.2", - "lazy_static", - "memchr", -] - [[package]] name = "password-hash" version = "0.4.2" @@ -7666,7 +7631,7 @@ version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ - "aho-corasick 1.1.2", + "aho-corasick", "memchr", "regex-automata 0.4.3", "regex-syntax 0.8.2", @@ -7687,7 +7652,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ - "aho-corasick 1.1.2", + "aho-corasick", "memchr", "regex-syntax 0.8.2", ] diff --git a/examples/PWA-example/src/main.rs b/examples/PWA-example/src/main.rs index 751834b39..3e4d5b236 100644 --- a/examples/PWA-example/src/main.rs +++ b/examples/PWA-example/src/main.rs @@ -5,7 +5,7 @@ fn main() { wasm_logger::init(wasm_logger::Config::default()); console_error_panic_hook::set_once(); - dioxus_web::launch(app); + launch(app); } fn app() -> Element { diff --git a/examples/mobile_demo/Cargo.toml b/examples/mobile_demo/Cargo.toml index e980774e7..a3219c015 100644 --- a/examples/mobile_demo/Cargo.toml +++ b/examples/mobile_demo/Cargo.toml @@ -2,7 +2,7 @@ name = "mobile-demo" version = "0.1.0" authors = ["Jonathan Kelley "] -edition = "2018" +edition = "2021" [lib] crate-type = ["staticlib", "cdylib", "rlib"] diff --git a/examples/query_segments_demo/src/main.rs b/examples/query_segments_demo/src/main.rs index 2e70ef7fc..903a545cc 100644 --- a/examples/query_segments_demo/src/main.rs +++ b/examples/query_segments_demo/src/main.rs @@ -83,5 +83,5 @@ fn App() -> Element { } fn main() { - dioxus_web::launch(App); + launch(App); } diff --git a/packages/cli/Cargo.toml b/packages/cli/Cargo.toml index c9222d854..fdadb4381 100644 --- a/packages/cli/Cargo.toml +++ b/packages/cli/Cargo.toml @@ -88,7 +88,7 @@ interprocess-docfix = { version = "1.2.2" } gitignore = "1.0.8" [features] -default = ["plugin"] +default = [] plugin = ["mlua"] [[bin]] diff --git a/packages/core/Cargo.toml b/packages/core/Cargo.toml index 90c0a744e..a07dee04e 100644 --- a/packages/core/Cargo.toml +++ b/packages/core/Cargo.toml @@ -2,7 +2,7 @@ name = "dioxus-core" version = { workspace = true } authors = ["Jonathan Kelley"] -edition = "2018" +edition = "2021" description = "Core functionality for Dioxus - a concurrent renderer-agnostic Virtual DOM for interactive user experiences" license = "MIT OR Apache-2.0" repository = "https://github.com/DioxusLabs/dioxus/" diff --git a/packages/desktop/Cargo.toml b/packages/desktop/Cargo.toml index 98393dcf2..85740328a 100644 --- a/packages/desktop/Cargo.toml +++ b/packages/desktop/Cargo.toml @@ -2,7 +2,7 @@ name = "dioxus-desktop" version = { workspace = true } authors = ["Jonathan Kelley"] -edition = "2018" +edition = "2021" description = "WebView renderer for Dioxus" license = "MIT OR Apache-2.0" repository = "https://github.com/DioxusLabs/dioxus/" @@ -83,8 +83,8 @@ dioxus = { workspace = true, features = ["launch", "desktop"]} exitcode = "1.1.2" [build-dependencies] -dioxus-interpreter-js = { workspace = true, features = ["binary-protocol"] } -minify-js = "0.5.6" +# dioxus-interpreter-js = { workspace = true, features = ["binary-protocol"] } +# minify-js = "0.5.6" # These tests need to be run on the main thread, so they cannot use rust's test harness. [[test]] diff --git a/packages/desktop/build.rs b/packages/desktop/_build.rs similarity index 100% rename from packages/desktop/build.rs rename to packages/desktop/_build.rs diff --git a/packages/desktop/src/launch.rs b/packages/desktop/src/launch.rs index cd32a7a94..334f32f95 100644 --- a/packages/desktop/src/launch.rs +++ b/packages/desktop/src/launch.rs @@ -66,7 +66,7 @@ pub fn launch_virtual_dom(virtual_dom: VirtualDom, desktop_config: Config) { /// Launches the WebView and runs the event loop, with configuration and root props. pub fn launch( root: fn() -> Element, - contexts: Vec Box>>, + contexts: Vec Box + Send + Sync>>, platform_config: Config, ) { let mut virtual_dom = VirtualDom::new(root); diff --git a/packages/dioxus/src/launch.rs b/packages/dioxus/src/launch.rs index f141e4876..61fe7a4af 100644 --- a/packages/dioxus/src/launch.rs +++ b/packages/dioxus/src/launch.rs @@ -16,10 +16,10 @@ pub struct LaunchBuilder { pub type LaunchFn = fn(fn() -> Element, ContextList, Cfg); -#[cfg(feature = "fullstack")] +// #[cfg(feature = "fullstack")] type ContextList = Vec Box + Send + Sync>>; -#[cfg(not(feature = "fullstack"))] -type ContextList = Vec Box>>; +// #[cfg(not(feature = "fullstack"))] +// type ContextList = Vec Box>>; impl LaunchBuilder { /// Create a new builder for your application. This will create a launch configuration for the current platform based on the features enabled on the `dioxus` crate. diff --git a/packages/fermi/Cargo.toml b/packages/fermi/Cargo.toml index 92a0ede71..45583f379 100644 --- a/packages/fermi/Cargo.toml +++ b/packages/fermi/Cargo.toml @@ -2,7 +2,7 @@ name = "fermi" version = { workspace = true } authors = ["Jonathan Kelley"] -edition = "2018" +edition = "2021" description = "Global state management for Dioxus" license = "MIT OR Apache-2.0" repository = "https://github.com/DioxusLabs/dioxus/" diff --git a/packages/fullstack/Cargo.toml b/packages/fullstack/Cargo.toml index 787671e6b..e5d892cf6 100644 --- a/packages/fullstack/Cargo.toml +++ b/packages/fullstack/Cargo.toml @@ -8,6 +8,7 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/DioxusLabs/dioxus/" homepage = "https://dioxuslabs.com" keywords = ["ui", "gui", "react", "ssr", "fullstack"] +resolver = "2" [dependencies] # server functions diff --git a/packages/fullstack/examples/axum-router/src/main.rs b/packages/fullstack/examples/axum-router/src/main.rs index c6447355d..8e8df2c1f 100644 --- a/packages/fullstack/examples/axum-router/src/main.rs +++ b/packages/fullstack/examples/axum-router/src/main.rs @@ -9,7 +9,7 @@ use dioxus_fullstack::prelude::*; use dioxus_router::prelude::*; fn main() { - let config = LaunchBuilder::>::router(); + let config = LaunchBuilder::fullstack(); #[cfg(feature = "ssr")] config .incremental( @@ -19,7 +19,12 @@ fn main() { .launch(); #[cfg(not(feature = "ssr"))] - config.launch(); + config.launch(|| { + rsx! { + Router:: { + } + } + }); } #[derive(Clone, Routable, Debug, PartialEq, serde::Serialize, serde::Deserialize)] @@ -36,9 +41,9 @@ fn Blog(id: i32) -> Element { Link { to: Route::Home {}, "Go to counter" } table { tbody { - for _ in 0..*id { + for _ in 0..id { tr { - for _ in 0..*id { + for _ in 0..id { td { "hello world!" } } } @@ -56,7 +61,7 @@ fn Home() -> Element { rsx! { Link { to: Route::Blog { - id: *count.get() + id: count() }, "Go to blog" } diff --git a/packages/fullstack/examples/salvo-hello-world/src/main.rs b/packages/fullstack/examples/salvo-hello-world/src/main.rs index fb6099129..3428578fe 100644 --- a/packages/fullstack/examples/salvo-hello-world/src/main.rs +++ b/packages/fullstack/examples/salvo-hello-world/src/main.rs @@ -9,34 +9,25 @@ use dioxus::prelude::*; use dioxus_fullstack::{launch, prelude::*}; use serde::{Deserialize, Serialize}; -#[derive(Props, PartialEq, Debug, Default, Serialize, Deserialize, Clone)] -struct AppProps { - count: i32, -} - -fn app(cx: Scope) -> Element { - let state = - use_server_future((), |()| async move { get_server_data().await.unwrap() })?.value(); +fn app() -> Element { + let state = use_server_future(move || async move { get_server_data().await.unwrap() }); let mut count = use_signal(|| 0); - let text = use_signal(|| "...".to_string()); + let mut text = use_signal(|| "...".to_string()); rsx! { div { - "Server state: {state}" + "Server state: {state.unwrap().value().clone()}" } h1 { "High-Five counter: {count}" } button { onclick: move |_| count += 1, "Up high!" } button { onclick: move |_| count -= 1, "Down low!" } button { - onclick: move |_| { - to_owned![text]; - async move { - if let Ok(data) = get_server_data().await { - println!("Client received: {}", data); - text.set(data.clone()); - post_server_data(data).await.unwrap(); - } + onclick: move |_| async move { + if let Ok(data) = get_server_data().await { + println!("Client received: {}", data); + text.set(data.clone()); + post_server_data(data).await.unwrap(); } }, "Run a server function!" @@ -63,5 +54,5 @@ fn main() { #[cfg(feature = "ssr")] tracing_subscriber::fmt::init(); - LaunchBuilder::new_with_props(app, AppProps { count: 0 }).launch() + LaunchBuilder::fullstack().launch(app); } diff --git a/packages/fullstack/src/lib.rs b/packages/fullstack/src/lib.rs index f0db380cb..2bd5a2fa3 100644 --- a/packages/fullstack/src/lib.rs +++ b/packages/fullstack/src/lib.rs @@ -66,8 +66,8 @@ pub mod prelude { } // Warn users about overlapping features -#[cfg(all(feature = "ssr", feature = "web"))] +#[cfg(all(feature = "ssr", feature = "web", not(doc)))] compile_error!("The `ssr` feature (enabled by `warp`, `axum`, or `salvo`) and `web` feature are overlapping. Please choose one or the other."); -#[cfg(all(feature = "ssr", feature = "desktop"))] +#[cfg(all(feature = "ssr", feature = "desktop", not(doc)))] compile_error!("The `ssr` feature (enabled by `warp`, `axum`, or `salvo`) and `desktop` feature are overlapping. Please choose one or the other."); diff --git a/packages/generational-box/Cargo.toml b/packages/generational-box/Cargo.toml index b27d0690b..09d1e76c3 100644 --- a/packages/generational-box/Cargo.toml +++ b/packages/generational-box/Cargo.toml @@ -2,7 +2,7 @@ name = "generational-box" authors = ["Evan Almloff"] version = "0.4.3" -edition = "2018" +edition = "2021" description = "A box backed by a generational runtime" license = "MIT OR Apache-2.0" repository = "https://github.com/DioxusLabs/dioxus/" diff --git a/packages/hooks/Cargo.toml b/packages/hooks/Cargo.toml index 74b90a5e0..f826a5ba3 100644 --- a/packages/hooks/Cargo.toml +++ b/packages/hooks/Cargo.toml @@ -2,7 +2,7 @@ name = "dioxus-hooks" version = { workspace = true } authors = ["Jonathan Kelley"] -edition = "2018" +edition = "2021" description = "Basic useful hooks for Dioxus." license = "MIT OR Apache-2.0" repository = "https://github.com/DioxusLabs/dioxus/" diff --git a/packages/html/Cargo.toml b/packages/html/Cargo.toml index 88874b162..8b8bd2df7 100644 --- a/packages/html/Cargo.toml +++ b/packages/html/Cargo.toml @@ -2,7 +2,7 @@ name = "dioxus-html" version = { workspace = true } authors = ["Jonathan Kelley"] -edition = "2018" +edition = "2021" description = "HTML Element pack for Dioxus - a concurrent renderer-agnostic Virtual DOM for interactive user experiences" license = "MIT OR Apache-2.0" repository = "https://github.com/DioxusLabs/dioxus/" diff --git a/packages/interpreter/Cargo.toml b/packages/interpreter/Cargo.toml index b2520a96a..009873a6e 100644 --- a/packages/interpreter/Cargo.toml +++ b/packages/interpreter/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dioxus-interpreter-js" version = { workspace = true } -edition = "2018" +edition = "2021" authors = ["Jonathan Kelley"] description = "JS Intepreter for Dioxus - a concurrent renderer-agnostic Virtual DOM for interactive user experiences" license = "MIT OR Apache-2.0" @@ -28,7 +28,7 @@ dioxus-html = { workspace = true, optional = true } default = [] serialize = ["serde"] sledgehammer = ["sledgehammer_bindgen", "sledgehammer_utils"] -web = [ +webonly = [ "sledgehammer", "wasm-bindgen", "js-sys", diff --git a/packages/interpreter/src/lib.rs b/packages/interpreter/src/lib.rs index 4feb2c7fe..b1aaebf04 100644 --- a/packages/interpreter/src/lib.rs +++ b/packages/interpreter/src/lib.rs @@ -17,7 +17,7 @@ mod write_native_mutations; pub use write_native_mutations::*; // Common bindings for minimal usage. -#[cfg(all(feature = "minimal_bindings", feature = "web"))] +#[cfg(all(feature = "minimal_bindings", feature = "webonly"))] pub mod minimal_bindings { use wasm_bindgen::{prelude::wasm_bindgen, JsValue}; #[wasm_bindgen(module = "/src/common.js")] diff --git a/packages/interpreter/src/sledgehammer_bindings.rs b/packages/interpreter/src/sledgehammer_bindings.rs index 1b63c05b5..e368d83f3 100644 --- a/packages/interpreter/src/sledgehammer_bindings.rs +++ b/packages/interpreter/src/sledgehammer_bindings.rs @@ -1,14 +1,14 @@ -#[cfg(feature = "web")] +#[cfg(feature = "webonly")] use js_sys::Function; -#[cfg(feature = "web")] +#[cfg(feature = "webonly")] use sledgehammer_bindgen::bindgen; -#[cfg(feature = "web")] +#[cfg(feature = "webonly")] use web_sys::Node; -#[cfg(feature = "web")] +#[cfg(feature = "webonly")] pub const SLEDGEHAMMER_JS: &str = GENERATED_JS; -#[cfg(feature = "web")] +#[cfg(feature = "webonly")] #[bindgen(module)] mod js { const JS_FILE: &str = "./src/common.js"; diff --git a/packages/liveview/Cargo.toml b/packages/liveview/Cargo.toml index ac5d12a55..50cb3346c 100644 --- a/packages/liveview/Cargo.toml +++ b/packages/liveview/Cargo.toml @@ -58,9 +58,9 @@ rocket = "0.5.0" rocket_ws = "0.1.0" tower = "0.4.13" -[build-dependencies] -dioxus-interpreter-js = { workspace = true, features = ["binary-protocol"] } -minify-js = "0.5.6" +# [build-dependencies] +# dioxus-interpreter-js = { workspace = true, features = ["binary-protocol"] } +# minify-js = "0.5.6" [features] default = ["hot-reload"] diff --git a/packages/liveview/build.rs b/packages/liveview/_build.rs similarity index 100% rename from packages/liveview/build.rs rename to packages/liveview/_build.rs diff --git a/packages/mobile/Cargo.toml b/packages/mobile/Cargo.toml index c0d84c8d4..924e17fc6 100644 --- a/packages/mobile/Cargo.toml +++ b/packages/mobile/Cargo.toml @@ -2,7 +2,7 @@ name = "dioxus-mobile" version = { workspace = true } authors = ["Jonathan Kelley"] -edition = "2018" +edition = "2021" description = "Mobile-compatible renderer for Dioxus" repository = "https://github.com/DioxusLabs/dioxus/" homepage = "https://dioxuslabs.com/learn/0.4/getting_started/mobile" diff --git a/packages/mobile/README.md b/packages/mobile/README.md index 425b69abb..1f774c016 100644 --- a/packages/mobile/README.md +++ b/packages/mobile/README.md @@ -49,7 +49,7 @@ We're going to completely clear out the `dependencies` it generates for us, swap name = "dioxus-ios-demo" version = "0.1.0" authors = ["Jonathan Kelley "] -edition = "2018" +edition = "2021" # leave the `lib` declaration diff --git a/packages/router/Cargo.toml b/packages/router/Cargo.toml index 8111954dc..011b957e5 100644 --- a/packages/router/Cargo.toml +++ b/packages/router/Cargo.toml @@ -2,7 +2,7 @@ name = "dioxus-router" authors = ["Jonathan Kelley", "Evan Almloff"] version = { workspace = true } -edition = "2018" +edition = "2021" description = "Cross-platform router for Dioxus apps" license = "MIT OR Apache-2.0" repository = "https://github.com/DioxusLabs/dioxus/" diff --git a/packages/rsx/Cargo.toml b/packages/rsx/Cargo.toml index 6f258b9da..57190daca 100644 --- a/packages/rsx/Cargo.toml +++ b/packages/rsx/Cargo.toml @@ -2,7 +2,7 @@ name = "dioxus-rsx" version = { workspace = true } authors = ["Jonathan Kelley", "Evan Almloff"] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" description = "Core functionality for Dioxus - a concurrent renderer-agnostic Virtual DOM for interactive user experiences" repository = "https://github.com/DioxusLabs/dioxus/" diff --git a/packages/signals/Cargo.toml b/packages/signals/Cargo.toml index 089e89bec..70b6ad953 100644 --- a/packages/signals/Cargo.toml +++ b/packages/signals/Cargo.toml @@ -2,7 +2,7 @@ name = "dioxus-signals" authors = ["Jonathan Kelley"] version = "0.4.3" -edition = "2018" +edition = "2021" description = "Signals for Dioxus" license = "MIT OR Apache-2.0" repository = "https://github.com/DioxusLabs/dioxus/" diff --git a/packages/signals/src/signal.rs b/packages/signals/src/signal.rs index e7fe5d22e..a1fba89aa 100644 --- a/packages/signals/src/signal.rs +++ b/packages/signals/src/signal.rs @@ -464,7 +464,7 @@ impl>> PartialEq for Signal { /// Allow calling a signal with signal() syntax /// /// Currently only limited to copy types, though could probably specialize for string/arc/rc -impl> + 'static> Deref for Signal { +impl> + 'static> Deref for Signal { type Target = dyn Fn() -> T; fn deref(&self) -> &Self::Target { @@ -473,7 +473,7 @@ impl> + 'static> Deref for Signal { // First we create a closure that captures something with the Same in memory layout as Self (MaybeUninit). let uninit_callable = MaybeUninit::::uninit(); // Then move that value into the closure. We assume that the closure now has a in memory layout of Self. - let uninit_closure = move || *Self::read(unsafe { &*uninit_callable.as_ptr() }); + let uninit_closure = move || Self::read(unsafe { &*uninit_callable.as_ptr() }).clone(); // Check that the size of the closure is the same as the size of Self in case the compiler changed the layout of the closure. let size_of_closure = std::mem::size_of_val(&uninit_closure); diff --git a/packages/ssr/Cargo.toml b/packages/ssr/Cargo.toml index e22f70024..d641b6437 100644 --- a/packages/ssr/Cargo.toml +++ b/packages/ssr/Cargo.toml @@ -2,7 +2,7 @@ name = "dioxus-ssr" version = { workspace = true } authors = ["Jonathan Kelley"] -edition = "2018" +edition = "2021" description = "Dioxus render-to-string" license = "MIT OR Apache-2.0" repository = "https://github.com/DioxusLabs/dioxus/" diff --git a/packages/web/Cargo.toml b/packages/web/Cargo.toml index 2486acbf8..8bc53ab9d 100644 --- a/packages/web/Cargo.toml +++ b/packages/web/Cargo.toml @@ -2,7 +2,7 @@ name = "dioxus-web" version = { workspace = true } authors = ["Jonathan Kelley"] -edition = "2018" +edition = "2021" description = "Web renderer for Dioxus using websys" license = "MIT OR Apache-2.0" repository = "https://github.com/DioxusLabs/dioxus/" @@ -14,7 +14,7 @@ dioxus-core = { workspace = true, features = ["serialize"] } dioxus-html = { workspace = true, features = ["wasm-bind"] } dioxus-interpreter-js = { workspace = true, features = [ "minimal_bindings", - "web", + "webonly", ] } js-sys = "0.3.56" diff --git a/packages/web/src/launch.rs b/packages/web/src/launch.rs index 760bcf87b..b647f715f 100644 --- a/packages/web/src/launch.rs +++ b/packages/web/src/launch.rs @@ -9,7 +9,7 @@ use std::any::Any; /// For a builder API, see `LaunchBuilder` defined in the `dioxus` crate. pub fn launch( root: fn() -> Element, - contexts: Vec Box>>, + contexts: Vec Box + Send + Sync>>, platform_config: Config, ) { let mut vdom = VirtualDom::new(root); diff --git a/playwright-tests/fullstack/src/main.rs b/playwright-tests/fullstack/src/main.rs index b1d8f8ccd..cf81897ec 100644 --- a/playwright-tests/fullstack/src/main.rs +++ b/playwright-tests/fullstack/src/main.rs @@ -54,23 +54,20 @@ struct AppProps { } #[allow(unused)] -fn app(cx: Scope) -> Element { - let mut count = use_signal(|| cx.props.count); - let text = use_signal(|| "...".to_string()); +fn app(props: AppProps) -> Element { + let mut count = use_signal(|| props.count); + let mut text = use_signal(|| "...".to_string()); rsx! { h1 { "hello axum! {count}" } button { class: "increment-button", onclick: move |_| count += 1, "Increment" } button { class: "server-button", - onclick: move |_| { - to_owned![text]; - async move { - if let Ok(data) = get_server_data().await { - println!("Client received: {}", data); - text.set(data.clone()); - post_server_data(data).await.unwrap(); - } + onclick: move |_| async move { + if let Ok(data) = get_server_data().await { + println!("Client received: {}", data); + text.set(data.clone()); + post_server_data(data).await.unwrap(); } }, "Run a server function!" diff --git a/playwright-tests/web/src/main.rs b/playwright-tests/web/src/main.rs index 2501ed70c..f013aae15 100644 --- a/playwright-tests/web/src/main.rs +++ b/playwright-tests/web/src/main.rs @@ -4,7 +4,7 @@ use dioxus::prelude::*; fn app() -> Element { let mut num = use_signal(|| 0); - let eval_result = use_signal(String::new); + let mut eval_result = use_signal(String::new); rsx! { div { @@ -22,19 +22,18 @@ fn app() -> Element { div { class: "style-div", color: "red", "colored text" } button { class: "eval-button", - onclick: move |_| { - let eval = eval( + onclick: move |_| async move { + let mut eval = eval( r#" window.document.title = 'Hello from Dioxus Eval!'; dioxus.send("returned eval value"); "#, ) .unwrap(); - async move { - let result = eval.recv().await; - if let Ok(serde_json::Value::String(string)) = result { - eval_result.set(string); - } + + let result = eval.recv().await; + if let Ok(serde_json::Value::String(string)) = result { + eval_result.set(string); } }, "Eval" @@ -44,5 +43,5 @@ fn app() -> Element { } fn main() { - launch_web(app); + launch(app); }