macro_rules! dom_renderer {
($register:path, $backend:ty, kind: $kind:expr, props: $props:ty, patch: $patch:ty,
make: $make:expr, update: $update:expr, measure: $measure:expr $(,)?) => { ... };
($register:path, $backend:ty, kind: $kind:expr, props: $props:ty, patch: $patch:ty,
make: $make:expr, update: $update:expr $(,)?) => { ... };
($register:path, $backend:ty, kind: $kind:expr, props: $props:ty,
make: $make:expr, measure: $measure:expr $(,)?) => { ... };
($register:path, $backend:ty, kind: $kind:expr, props: $props:ty, make: $make:expr $(,)?) => { ... };
}Expand description
Register a piece’s web-dom renderer, whose registry is populated at RUNTIME.
linkme has no wasm32-unknown-unknown implementation (DESIGN.md §8.2), so day-dom keeps a
Registry<Dom> that pieces add to by calling day_dom::register_renderer. This macro is
renderer!’s counterpart for that seam: same typed make/update/measure, same inserted
downcast, but it defines an idempotent pub(crate) fn register() instead of a static — and the
piece’s own constructor must call it, which is the one line web pieces write that link-time ones
don’t:
ⓘ
// lib-dom.rs
day_pieces::dom_renderer!(day_dom::register_renderer, day_dom::Dom,
kind: KIND, props: MyProps, patch: MyPatch, make: make, update: update, measure: measure);
// lib.rs — a constructor always runs before the node it returns is realized.
pub fn my_piece(…) -> MyPiece {
#[cfg(all(feature = "dom", target_arch = "wasm32"))]
dom_impl::register();
…
}One dom_renderer! per module.