|
@@ -6,16 +6,21 @@ pub type Config = crate::Config<axum::Router>;
|
|
/// Launches the WebView and runs the event loop, with configuration and root props.
|
|
/// Launches the WebView and runs the event loop, with configuration and root props.
|
|
pub fn launch(
|
|
pub fn launch(
|
|
root: fn() -> Element,
|
|
root: fn() -> Element,
|
|
- contexts: Vec<Box<dyn Fn() -> Box<dyn Any + Send + Sync> + Send + Sync>>,
|
|
|
|
- platform_config: Config,
|
|
|
|
|
|
+ contexts: Vec<Box<dyn Fn() -> Box<dyn Any> + Send + Sync>>,
|
|
|
|
+ platform_configs: Vec<Box<dyn Any>>,
|
|
) -> ! {
|
|
) -> ! {
|
|
#[cfg(feature = "multi-thread")]
|
|
#[cfg(feature = "multi-thread")]
|
|
let mut builder = tokio::runtime::Builder::new_multi_thread();
|
|
let mut builder = tokio::runtime::Builder::new_multi_thread();
|
|
#[cfg(not(feature = "multi-thread"))]
|
|
#[cfg(not(feature = "multi-thread"))]
|
|
let mut builder = tokio::runtime::Builder::new_current_thread();
|
|
let mut builder = tokio::runtime::Builder::new_current_thread();
|
|
|
|
|
|
|
|
+ let config = platform_configs
|
|
|
|
+ .into_iter()
|
|
|
|
+ .find_map(|cfg| cfg.downcast::<Config>().ok().map(|cfg| *cfg))
|
|
|
|
+ .unwrap_or_default();
|
|
|
|
+
|
|
builder.enable_all().build().unwrap().block_on(async move {
|
|
builder.enable_all().build().unwrap().block_on(async move {
|
|
- platform_config
|
|
|
|
|
|
+ config
|
|
.with_virtual_dom(move || {
|
|
.with_virtual_dom(move || {
|
|
let mut virtual_dom = VirtualDom::new(root);
|
|
let mut virtual_dom = VirtualDom::new(root);
|
|
|
|
|