1pub use crate::Config;
4use dioxus_core::prelude::*;
5use std::any::Any;
6
7pub fn launch(
11 root: fn() -> Element,
12 contexts: Vec<Box<dyn Fn() -> Box<dyn Any> + Send + Sync>>,
13 platform_config: Vec<Box<dyn Any>>,
14) {
15 let mut vdom = VirtualDom::new(root);
16 for context in contexts {
17 vdom.insert_any_root_context(context());
18 }
19
20 let platform_config = *platform_config
21 .into_iter()
22 .find_map(|cfg| cfg.downcast::<Config>().ok())
23 .unwrap_or_default();
24 launch_virtual_dom(vdom, platform_config)
25}
26
27pub fn launch_virtual_dom(vdom: VirtualDom, platform_config: Config) {
31 wasm_bindgen_futures::spawn_local(async move {
32 crate::run(vdom, platform_config).await;
33 });
34}
35
36pub fn launch_cfg(root: fn() -> Element, platform_config: Config) {
38 launch(root, Vec::new(), vec![Box::new(platform_config)])
39}