Clone in a terminal:
Commit 3521197
Johan Mattsson - 2026-06-28T18:26:25+00:00
3521197e69fa084b21e97390319d8296a7452b9cjohan.mattsson.m@gmail.com

Macro update

Changed files (2)

Diff

diff --git a/src/lib.rs b/src/lib.rsindex b12a57c..182e4e1 100644--- a/src/lib.rs+++ b/src/lib.rs@@ -15,6 +15,11 @@ inventory::collect!(InitFn); pub struct InitComponentFn(pub fn()); inventory::collect!(InitComponentFn); +/// Global counter shared by all components created by the #[component] macro.+/// The proc-macro-generated code will increment this to obtain a unique wasm id.+pub static NEXT_COMPONENT_COUNTER: std::sync::atomic::AtomicU32 =+    std::sync::atomic::AtomicU32::new(1);+ #[derive(Debug, Clone, Copy)] pub struct Error; @@ -53,11 +58,17 @@ inventory::collect!(CallbackRegistration); /// }}; /// ``` pub fn init_callbacks() {-    for init in inventory::iter::<InitComponentFn> {+    log!("init_callbacks");++    log!("init_callbacks functions");+    for init in inventory::iter::<InitFn> {+        log!("init fn");         (init.0)();     } -    for init in inventory::iter::<InitFn> {+    log!("init_callbacks components");+    for init in inventory::iter::<InitComponentFn> {+        log!("init component");         (init.0)();     } }@@ -310,7 +321,7 @@ pub fn get_callback(name: &str) -> Option<js_sys::Function> { pub trait Component {     fn connected(&mut self, element: HtmlElement) {}     fn disconnected(&mut self, element: HtmlElement) {}-    fn observed_attributes() -> &'static [&'static str] {+    fn observed_attributes(element: HtmlElement) -> &'static [&'static str] {         &[]     } diff --git a/src/prelude.rs b/src/prelude.rsindex 1f6a256..ccb3bcb 100644--- a/src/prelude.rs+++ b/src/prelude.rs@@ -1,7 +1,7 @@ pub use crate::{-    CallbackRegistration, Error, InitComponentFn, InitFn, Result, get_callback, get_cookie_value,-    get_element, get_elements, get_value, init_callbacks, inner_html, inner_text, try_get_value,-    try_inner_html, try_inner_text,+    CallbackRegistration, Component, Error, InitComponentFn, InitFn, Result, get_callback,+    get_cookie_value, get_element, get_elements, get_value, init_callbacks, inner_html, inner_text,+    try_get_value, try_inner_html, try_inner_text, };  pub use gloo::console::error;

Contact

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