diff --git a/packages/desktop/src/desktop_context.rs b/packages/desktop/src/desktop_context.rs index e5f928222..edddd7887 100644 --- a/packages/desktop/src/desktop_context.rs +++ b/packages/desktop/src/desktop_context.rs @@ -9,6 +9,7 @@ use crate::Config; use crate::WebviewHandler; use dioxus_core::ScopeState; use dioxus_core::VirtualDom; +#[cfg(all(feature = "hot-reload", debug_assertions))] use dioxus_hot_reload::HotReloadMsg; use serde_json::Value; use slab::Slab; @@ -285,6 +286,7 @@ pub enum EventData { Ipc(IpcMessage), + #[cfg(all(feature = "hot-reload", debug_assertions))] HotReloadEvent(HotReloadMsg), NewWindow, diff --git a/packages/desktop/src/lib.rs b/packages/desktop/src/lib.rs index dea69e532..16f562464 100644 --- a/packages/desktop/src/lib.rs +++ b/packages/desktop/src/lib.rs @@ -185,6 +185,7 @@ pub fn launch_with_props(root: Component

, props: P, cfg: Config) } Event::UserEvent(event) => match event.0 { + #[cfg(all(feature = "hot-reload", debug_assertions))] EventData::HotReloadEvent(msg) => match msg { dioxus_hot_reload::HotReloadMsg::UpdateTemplate(template) => { for webview in webviews.values_mut() { diff --git a/packages/liveview/src/pool.rs b/packages/liveview/src/pool.rs index b3ed6bef5..022641d5c 100644 --- a/packages/liveview/src/pool.rs +++ b/packages/liveview/src/pool.rs @@ -134,7 +134,7 @@ where #[cfg(all(feature = "hot-reload", debug_assertions))] let hot_reload_wait = hot_reload_rx.recv(); #[cfg(not(all(feature = "hot-reload", debug_assertions)))] - let hot_reload_wait = std::future::pending(); + let hot_reload_wait: std::future::Pending> = std::future::pending(); tokio::select! { // poll any futures or suspense @@ -157,17 +157,18 @@ where } } - msg = hot_reload_wait => { - if let Some(msg) = msg { - match msg{ - dioxus_hot_reload::HotReloadMsg::UpdateTemplate(new_template) => { - vdom.replace_template(new_template); - } - dioxus_hot_reload::HotReloadMsg::Shutdown => { - std::process::exit(0); - }, + Some(msg) = hot_reload_wait => { + #[cfg(all(feature = "hot-reload", debug_assertions))] + match msg{ + dioxus_hot_reload::HotReloadMsg::UpdateTemplate(new_template) => { + vdom.replace_template(new_template); } + dioxus_hot_reload::HotReloadMsg::Shutdown => { + std::process::exit(0); + }, } + #[cfg(not(all(feature = "hot-reload", debug_assertions)))] + let () = msg; } } diff --git a/packages/tui/src/lib.rs b/packages/tui/src/lib.rs index c7f1dcc79..75c865de5 100644 --- a/packages/tui/src/lib.rs +++ b/packages/tui/src/lib.rs @@ -22,7 +22,7 @@ use std::{ use std::{io, time::Duration}; use taffy::Taffy; pub use taffy::{geometry::Point, prelude::*}; -use tokio::{select, sync::mpsc::unbounded_channel}; +use tokio::select; use tui::{backend::CrosstermBackend, layout::Rect, Terminal}; mod config; @@ -148,7 +148,7 @@ fn render_vdom( #[cfg(all(feature = "hot-reload", debug_assertions))] let mut hot_reload_rx = { let (hot_reload_tx, hot_reload_rx) = - unbounded_channel::(); + tokio::sync::mpsc::unbounded_channel::(); dioxus_hot_reload::connect(move |msg| { let _ = hot_reload_tx.send(msg); }); @@ -233,13 +233,14 @@ fn render_vdom( } } + #[cfg(all(feature = "hot-reload", debug_assertions))] let mut hot_reload_msg = None; { let wait = vdom.wait_for_work(); #[cfg(all(feature = "hot-reload", debug_assertions))] let hot_reload_wait = hot_reload_rx.recv(); #[cfg(not(all(feature = "hot-reload", debug_assertions)))] - let hot_reload_wait = std::future::pending(); + let hot_reload_wait: std::future::Pending> = std::future::pending(); pin_mut!(wait); @@ -269,12 +270,18 @@ fn render_vdom( } }, Some(msg) = hot_reload_wait => { - hot_reload_msg = Some(msg); + #[cfg(all(feature = "hot-reload", debug_assertions))] + { + hot_reload_msg = Some(msg); + } + #[cfg(not(all(feature = "hot-reload", debug_assertions)))] + let () = msg; } } } // if we have a new template, replace the old one + #[cfg(all(feature = "hot-reload", debug_assertions))] if let Some(msg) = hot_reload_msg { match msg { dioxus_hot_reload::HotReloadMsg::UpdateTemplate(template) => {