integrate liveview with the launch builder
This commit is contained in:
1 parent
50873bf9c7
commit
636aeb4b90
20 files changed
+443
-97
No files matched your search
@@ -0,0 +1,35 @@
|
||||
use dioxus_core::*;
|
||||
use std::any::Any;
|
||||
|
||||
#[cfg(feature = "axum")]
|
||||
pub type Config = crate::Config<axum::Router>;
|
||||
#[cfg(feature = "salvo")]
|
||||
pub type Config = crate::Config<salvo::Router>;
|
||||
#[cfg(feature = "rocket")]
|
||||
pub type Config = crate::Config<rocket::Rocket<rocket::Build>>;
|
||||
|
||||
/// Launches the WebView and runs the event loop, with configuration and root props.
|
||||
pub fn launch(
|
||||
root: fn() -> Element,
|
||||
contexts: Vec<Box<dyn Fn() -> Box<dyn Any> + Send + Sync>>,
|
||||
platform_config: Config,
|
||||
) {
|
||||
tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap()
|
||||
.block_on(async move {
|
||||
platform_config
|
||||
.with_virtual_dom(move || {
|
||||
let mut virtual_dom = VirtualDom::new(root);
|
||||
|
||||
for context in &contexts {
|
||||
virtual_dom.insert_any_root_context(context());
|
||||
}
|
||||
|
||||
virtual_dom
|
||||
})
|
||||
.launch()
|
||||
.await;
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user