Browse Source

fix the web platform

Evan Almloff 1 year ago
parent
commit
cb5a43c120
3 changed files with 23 additions and 23 deletions
  1. 22 0
      packages/web/src/launch.rs
  2. 1 2
      packages/web/src/lib.rs
  3. 0 21
      packages/web/src/platform.rs

+ 22 - 0
packages/web/src/launch.rs

@@ -0,0 +1,22 @@
+//! This module contains the `launch` function, which is the main entry point for dioxus web
+
+pub use crate::Config;
+use dioxus_core::prelude::*;
+use std::any::Any;
+
+/// Launch the web application with the given root component, context and config
+///
+/// For a builder API, see `LaunchBuilder` defined in the `dioxus` crate.
+pub fn launch(
+    root: fn() -> Element,
+    contexts: Vec<Box<dyn Fn() -> Box<dyn Any>>>,
+    platform_config: Config,
+) {
+    wasm_bindgen_futures::spawn_local(async move {
+        let mut vdom = VirtualDom::new(root);
+        for context in contexts {
+            vdom.insert_any_root_context(context());
+        }
+        crate::run(vdom, platform_config).await;
+    });
+}

+ 1 - 2
packages/web/src/lib.rs

@@ -71,10 +71,9 @@ mod dom;
 #[cfg(feature = "eval")]
 mod eval;
 mod event;
+pub mod launch;
 mod mutations;
-mod platform;
 pub use event::*;
-pub use platform::*;
 #[cfg(feature = "file_engine")]
 mod file_engine;
 #[cfg(all(feature = "hot_reload", debug_assertions))]

+ 0 - 21
packages/web/src/platform.rs

@@ -1,21 +0,0 @@
-pub mod launch {
-    use std::any::Any;
-
-    use dioxus_core::prelude::*;
-
-    pub type Config = crate::Config;
-
-    pub fn launch(
-        root: fn() -> Element,
-        contexts: Vec<Box<dyn Fn() -> Box<dyn Any> + Send>>,
-        platform_config: Config,
-    ) {
-        wasm_bindgen_futures::spawn_local(async move {
-            let mut vdom = VirtualDom::new(root);
-            for context in contexts {
-                vdom.insert_any_root_context(context());
-            }
-            crate::run(vdom, platform_config).await;
-        });
-    }
-}