Clone in a terminal:
Commit 0a24792
Johan Mattsson - 2026-06-29T16:41:35+00:00
0a24792460495eb1e178f8057d995b271dbfe6a2johan.mattsson.m@gmail.com

Update example

Changed files (1)

Diff

diff --git a/examples/counter-component/src/counter.rs b/examples/counter-component/src/counter.rsindex 4672a79..54407e9 100644--- a/examples/counter-component/src/counter.rs+++ b/examples/counter-component/src/counter.rs@@ -75,20 +75,24 @@ pub fn increment(id: String) {         return;     } -    let count = count_attribute-        .and_then(|s| s.parse::<i32>().ok())-        .unwrap_or(-1);+    let count = count_attribute.unwrap().parse::<i32>(); -    let new_count = count + 1;+    if !count.is_ok() {+        error!("Count is not an integer.");+        return;+    }++    let mut current_count = count.unwrap();+    current_count += 1;      if let Some(counter_arc) = get_component::<Counter>(id.as_str()) {         let mut counter = counter_arc.lock().unwrap();-        counter.value = new_count;+        counter.value = current_count;         counter.render(&html_element);     } else {         error!("Component not found for id", id);         return;     } -    let _ = html_element.set_attribute("count", new_count.to_string().as_str());+    let _ = html_element.set_attribute("count", current_count.to_string().as_str()); }

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112