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