mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 04:33:06 +00:00
fix the liveview launch function
This commit is contained in:
parent
930f8bffbc
commit
a428c61457
2 changed files with 19 additions and 17 deletions
|
@ -41,8 +41,9 @@ tower = { workspace = true }
|
||||||
dioxus = { workspace = true }
|
dioxus = { workspace = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["hot-reload"]
|
default = ["hot-reload", "multi-thread"]
|
||||||
axum = ["dep:axum"]
|
axum = ["dep:axum"]
|
||||||
|
multi-thread = ["tokio/rt-multi-thread"]
|
||||||
hot-reload = ["dioxus-hot-reload"]
|
hot-reload = ["dioxus-hot-reload"]
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
|
|
|
@ -9,22 +9,23 @@ pub fn launch(
|
||||||
contexts: Vec<Box<dyn Fn() -> Box<dyn Any> + Send + Sync>>,
|
contexts: Vec<Box<dyn Fn() -> Box<dyn Any> + Send + Sync>>,
|
||||||
platform_config: Config,
|
platform_config: Config,
|
||||||
) {
|
) {
|
||||||
tokio::runtime::Builder::new_multi_thread()
|
#[cfg(feature = "multi-threaded")]
|
||||||
.enable_all()
|
let mut builder = tokio::runtime::Builder::new_multi_thread();
|
||||||
.build()
|
#[cfg(not(feature = "multi-threaded"))]
|
||||||
.unwrap()
|
let mut builder = tokio::runtime::Builder::new_current_thread();
|
||||||
.block_on(async move {
|
|
||||||
platform_config
|
|
||||||
.with_virtual_dom(move || {
|
|
||||||
let mut virtual_dom = VirtualDom::new(root);
|
|
||||||
|
|
||||||
for context in &contexts {
|
builder.enable_all().build().unwrap().block_on(async move {
|
||||||
virtual_dom.insert_any_root_context(context());
|
platform_config
|
||||||
}
|
.with_virtual_dom(move || {
|
||||||
|
let mut virtual_dom = VirtualDom::new(root);
|
||||||
|
|
||||||
virtual_dom
|
for context in &contexts {
|
||||||
})
|
virtual_dom.insert_any_root_context(context());
|
||||||
.launch()
|
}
|
||||||
.await;
|
|
||||||
});
|
virtual_dom
|
||||||
|
})
|
||||||
|
.launch()
|
||||||
|
.await;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue