mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-30 08:00:21 +00:00
fix the web renderer panicing when the hot reload connection fails
This commit is contained in:
parent
6c6df1e2fd
commit
8e007cc137
1 changed files with 12 additions and 11 deletions
|
@ -61,10 +61,7 @@ pub use crate::cfg::Config;
|
||||||
#[cfg(feature = "file_engine")]
|
#[cfg(feature = "file_engine")]
|
||||||
pub use crate::file_engine::WebFileEngineExt;
|
pub use crate::file_engine::WebFileEngineExt;
|
||||||
use dioxus_core::VirtualDom;
|
use dioxus_core::VirtualDom;
|
||||||
use futures_util::{
|
use futures_util::{pin_mut, select, FutureExt, StreamExt};
|
||||||
future::{select, Either},
|
|
||||||
pin_mut, FutureExt, StreamExt,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod cfg;
|
mod cfg;
|
||||||
mod dom;
|
mod dom;
|
||||||
|
@ -159,17 +156,21 @@ pub async fn run(virtual_dom: VirtualDom, web_config: Config) {
|
||||||
let (mut res, template) = {
|
let (mut res, template) = {
|
||||||
let work = dom.wait_for_work().fuse();
|
let work = dom.wait_for_work().fuse();
|
||||||
pin_mut!(work);
|
pin_mut!(work);
|
||||||
|
let mut rx_next = rx.select_next_some();
|
||||||
|
|
||||||
#[cfg(all(feature = "hot_reload", debug_assertions))]
|
#[cfg(all(feature = "hot_reload", debug_assertions))]
|
||||||
match select(work, select(hotreload_rx.next(), rx.next())).await {
|
{
|
||||||
Either::Left((_, _)) => (None, None),
|
let mut hot_reload_next = hotreload_rx.select_next_some();
|
||||||
Either::Right((Either::Left((new_template, _)), _)) => (None, new_template),
|
select! {
|
||||||
Either::Right((Either::Right((evt, _)), _)) => (evt, None),
|
_ = work => (None, None),
|
||||||
|
new_template = hot_reload_next => (None, Some(new_template)),
|
||||||
|
evt = rx_next => (Some(evt), None),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[cfg(not(all(feature = "hot_reload", debug_assertions)))]
|
#[cfg(not(all(feature = "hot_reload", debug_assertions)))]
|
||||||
match select(work, rx.next()).await {
|
select! {
|
||||||
Either::Left((_, _)) => (None, None),
|
_ = work => (None, None),
|
||||||
Either::Right((evt, _)) => (evt, None),
|
evt = rx_next => (Some(evt), None),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue