fix conditional compilation for hot reloading
This commit is contained in:
1 parent
e2a73127f3
commit
773a87d701
4 files changed
+25
-14
No files matched your search
+11
-4
@@ -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::<dioxus_hot_reload::HotReloadMsg>();
|
||||
tokio::sync::mpsc::unbounded_channel::<dioxus_hot_reload::HotReloadMsg>();
|
||||
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<Option<()>> = 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) => {
|
||||
|
||||
Reference in new issue
Block a user