Merge pull request #2073 from ealmloff/fix-liveview-launch-builder

Fix the liveview launch function
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-03-13 14:10:22 -07:00
commit 979df05546
2 files changed
+8 -6

No files matched your search

+2 -1
View File
@@ -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]]
+6 -5
View File
@@ -9,11 +9,12 @@ 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 {
builder.enable_all().build().unwrap().block_on(async move {
platform_config platform_config
.with_virtual_dom(move || { .with_virtual_dom(move || {
let mut virtual_dom = VirtualDom::new(root); let mut virtual_dom = VirtualDom::new(root);