mogwai 0.7.6
Released 2026-07-15.
Breaking changes
mogwai-macrosbumped from 0.2.0 to 0.2.2. Themogwai-macrosdependency
inmogwai/Cargo.tomlnow requires>= 0.2.1.web-sysfeature:"console"added to the requiredweb-sysfeatures
list. If your downstreamCargo.tomlpinsweb-sysfeatures explicitly,
add"console".
New features
Listener and Callback — a generic JS callback bridge
(mogwai::web::event)
A new low-level event primitive that generalizes the existing EventListener
pattern beyond DOM events. Listener<I, O> and Callback<Params> let you
wrap any JavaScript callback — not just addEventListener-style DOM events
— and await it as a Rust future. The input type I is a tuple matching the JS
callback's arity (0 through 8):
let (callback, listener) = Listener::new(|(v,): (JsValue,)| v.as_f64().unwrap_or(0.0));
// Give callback.function() to any JS API that expects a function.
some_js_obj.set_on_event(Some(callback.function()));
let value: f64 = listener.next().await;Multiple calls to listener.next() before the next callback invocation all
resolve simultaneously (fan-out). Each next() call returns a fresh,
independent future. Callback is Clone and must be kept alive for as long
as JS might invoke it.
EventListener is now a thin convenience wrapper around
Listener<(JsValue,), web_sys::Event>.
#[derive(ViewProperties)]
(mogwai-macros)
A new derive macro that proxies all ViewProperties trait methods to a field
annotated with #[properties]. Works alongside the existing
#[derive(ViewChild)] with #[child]:
#[derive(ViewChild, ViewProperties)]
struct MyComponent<V: View> {
#[child]
#[properties]
wrapper: V::Element,
}
// component.set_property("class", "active") now delegates to wrapper.The #[child] and #[properties] annotations can be on the same field or
separate fields.
ViewProperties::add_class / remove_class
(mogwai::view)
Convenience methods on the ViewProperties trait for adding/removing CSS
classes by string. Idempotent — adding a class that already exists is a no-op,
removing a class that isn't present is a no-op.
mogwai::future::merge_all
(mogwai::future)
Run all futures concurrently and collect their outputs into a Vec<T>.
Companion to the existing race_all (which returns the first to resolve):
let results = merge_all([run(10), run(100), run(200)]).await;
assert_eq!(results.len(), 3);Bug fixes
- SSR output no longer contains stray whitespace or
println!output.
Removed debugprintln!("appending node...")and
println!("setting proxy")/println!("proxy is unchanged")/
println!("modifying proxy")fromssr.rsandproxy.rs. Added a test
(ssr::tests::no_whitespace) verifying SSR output has no extraneous
whitespace between elements. - DOM operations no longer panic on error.
web_sys::Node::append_child,
remove_child,replace_child, andinsert_beforeinweb.rsnow
silently discard errors (let _ = ...) instead ofunwrap_throw(). This
prevents panics when, e.g., a node is moved between documents or the DOM is
in an unexpected state. - SSR style merging: the
let ... elsepattern is now used for the
style-merge logic inSsrElement::set_style, fixing a clippy lint and making
the control flow clearer.
Improvements
- Documentation overhaul for
mogwai::web::event: new module-level docs
with architecture diagram, "when to use which" guidance (EventListenervs
Listener/Callback), lifecycle warnings forCallback, arity table, and
usage examples. - Doc comment line wrapping across
web.rs,view.rs,time.rs,
ssr.rs, and macro docs for consistent rendering on docs.rs. mogwai-macrosCargo.toml: addedlicense,description,
documentation,repository,readme,keywords, andcategoriesfields
for crates.io metadata.
Internal
- Cookbook build commented out until ported to the new API.
- Dependency updates.
- New
impl_parameters_tuples!proc macro inmogwai-macrosthat generates
Parameterstrait impls for tuple arities 2 through 8, used by the new
Listener/Callbacksystem.
Migration guide
- If you were using
EventListenerdirectly, no changes needed — it's the
same API, now built onListenerinternally. - If you have custom components that manually implement
ViewPropertiesby
delegating to an innerV::Element, you can replace the manual impl with
#[derive(ViewProperties)]and a#[properties]field annotation. - If you pin
web-sysfeatures in your downstream crate, add"console"to
the features list. - If you were working around stray
println!output in SSR, those are now
gone — remove any whitespace-stripping workarounds.