diff --git a/crates/sauron-core/src/dom/program.rs b/crates/sauron-core/src/dom/program.rs index 30ec7996c..89185f5a5 100644 --- a/crates/sauron-core/src/dom/program.rs +++ b/crates/sauron-core/src/dom/program.rs @@ -249,11 +249,10 @@ where /// clone the app pub fn app_clone(&self) -> APP { /* + //TODO: This doesn't work all the time, maybe use Arc::RwLock as a replacement to + //Rc::RefCell unsafe{ - log::debug!("size APP: {}", std::mem::size_of::()); - let borrowed_app = self.app_context.app.borrow(); - log::debug!("size of borrowed_app: {}", std::mem::size_of_val(&*borrowed_app)); - let app: APP = std::mem::transmute_copy(&*borrowed_app); + let app: APP = std::mem::transmute_copy(&*self.app_context.app.borrow()); app } */ @@ -551,6 +550,8 @@ where let patches = treepath.into_iter().flat_map(|path|{ let new_node = path.find_node_by_path(new_vdom).expect("new_node"); let old_node = path.find_node_by_path(¤t_vdom).expect("old_node"); + log::debug!("new_node: {new_node:#?}"); + log::debug!("old_node: {old_node:#?}"); diff_recursive( &old_node, &new_node, @@ -704,7 +705,10 @@ where } - let treepath = self.app().pre_eval(&old_app).map(|eval|Eval::traverse(&eval)); + let treepath = self.app().pre_eval(&old_app).map(|eval|{ + log::debug!("eval: {eval:#?}"); + Eval::traverse(&eval) + }); let cmd = self.app_context.batch_pending_cmds(); diff --git a/crates/sauron-core/src/html.rs b/crates/sauron-core/src/html.rs index a0dffbe19..88dced08d 100644 --- a/crates/sauron-core/src/html.rs +++ b/crates/sauron-core/src/html.rs @@ -79,7 +79,9 @@ pub fn html_element( let mut corrected_children: Vec> = vec![]; for child in children { if let Some(last) = corrected_children.last() { - if last.is_text() { + //TODO: put this behind a flag: #auto-separator to automatically + //add separator between text nodes + if last.is_text() && child.is_text(){ corrected_children.push(comment("separator")); } } diff --git a/examples/interactive/src/app.rs b/examples/interactive/src/app.rs index b16cbfadb..58f42cb10 100644 --- a/examples/interactive/src/app.rs +++ b/examples/interactive/src/app.rs @@ -54,6 +54,7 @@ impl Application for App { match msg { Msg::Click => { self.click_count += 1; + log::info!("click count: {}", self.click_count); } Msg::DoubleClick => { self.double_clicks += 1; @@ -78,6 +79,47 @@ impl Application for App { Cmd::none() } + fn pre_eval(&self, old: &Self) -> Option> { + Some(vec![ + eval(false, + [ + eval(false, [eval(true, [])]), + eval(false, + [ + eval(false, []), + eval(false, []), + eval(false, []), + eval(false, + [eval(self.double_clicks != old.double_clicks, [])], + ), + ], + ), + eval(false, + [ + eval(self.name != old.name, []), + eval(false, []), // separator for in between text here + eval(self.click_count != old.click_count, []) + ], + ), + eval(false, + [ + eval(false, []), + eval(false, []), + eval(false, [eval(self.biography != old.biography, [])]), + ], + ), + eval(false, + [ + eval(false, []), + eval(false, []), + eval(self.thought != old.thought, []), + ], + ), + ], + )] + ) + } + fn view(&self) -> Node { let date_str: String = self .date @@ -126,7 +168,7 @@ impl Application for App { if self.click_count > 1 { "s" } else { "" } ) } else { - span([], []) + text("here..") }, ], ),