Pārlūkot izejas kodu

Chore: comments

Jonathan Kelley 4 gadi atpakaļ
vecāks
revīzija
18a7a1f9c4
2 mainītis faili ar 13 papildinājumiem un 9 dzēšanām
  1. 3 1
      packages/core/src/virtual_dom.rs
  2. 10 8
      packages/web/src/lib.rs

+ 3 - 1
packages/core/src/virtual_dom.rs

@@ -78,7 +78,9 @@ impl VirtualDom {
         }
     }
 
-    //// Performs a *full* rebuild of the virtual dom, returning every edit required to generate the actual dom
+    /// Performs a *full* rebuild of the virtual dom, returning every edit required to generate the actual dom.
+    ///
+    ///
     pub fn rebuild(&mut self) -> Result<EditList<'_>> {
         // Reset and then build a new diff machine
         // The previous edit list cannot be around while &mut is held

+ 10 - 8
packages/web/src/lib.rs

@@ -56,8 +56,8 @@ impl WebsysRenderer {
     }
 
     /// Create a new text renderer from an existing Virtual DOM.
-    /// This will progress the existing VDom's events to completion.
     pub fn from_vdom(dom: VirtualDom) -> Self {
+        // todo: initialize the event registry properly
         Self {
             internal_dom: dom,
             _event_map: FxHashMap::default(),
@@ -67,15 +67,17 @@ impl WebsysRenderer {
     pub async fn run(&mut self) -> dioxus_core::error::Result<()> {
         let (sender, mut receiver) = mpsc::unbounded::<EventTrigger>();
 
-        let body = prepare_websys_dom();
-        let mut patch_machine = interpreter::PatchMachine::new(body.clone());
-        let root_node = body.first_child().unwrap();
+        let body_element = prepare_websys_dom();
+        let mut patch_machine = interpreter::PatchMachine::new(body_element.clone());
+        let root_node = body_element.first_child().unwrap();
         patch_machine.stack.push(root_node);
 
+        // todo: initialize the event registry properly on the root element
+
         self.internal_dom
             .rebuild()?
-            .into_iter()
-            .for_each(|edit| patch_machine.handle_edit(&edit));
+            .iter()
+            .for_each(|edit| patch_machine.handle_edit(edit));
 
         // Event loop waits for the receiver to finish up
         // TODO! Connect the sender to the virtual dom's suspense system
@@ -83,9 +85,9 @@ impl WebsysRenderer {
         while let Some(event) = receiver.next().await {
             self.internal_dom
                 .progress_with_event(event)?
-                .into_iter()
+                .iter()
                 .for_each(|edit| {
-                    patch_machine.handle_edit(&edit);
+                    patch_machine.handle_edit(edit);
                 });
         }