diff --git a/leptos_dom/Cargo.toml b/leptos_dom/Cargo.toml index f9e345a33..7ae65aa3b 100644 --- a/leptos_dom/Cargo.toml +++ b/leptos_dom/Cargo.toml @@ -17,6 +17,7 @@ base64 = { version = "0.21", optional = true } getrandom = { version = "0.2", optional = true } js-sys = "0.3" rand = { version = "0.8", optional = true } +send_wrapper = "0.6" tracing = "0.1" wasm-bindgen = "0.2" diff --git a/leptos_dom/src/helpers.rs b/leptos_dom/src/helpers.rs index 14ed4a4ab..7961829be 100644 --- a/leptos_dom/src/helpers.rs +++ b/leptos_dom/src/helpers.rs @@ -4,6 +4,7 @@ use or_poisoned::OrPoisoned; #[cfg(debug_assertions)] use reactive_graph::diagnostics::SpecialNonReactiveZone; use reactive_graph::owner::Owner; +use send_wrapper::SendWrapper; use std::time::Duration; use tachys::html::event::EventDescriptor; #[cfg(feature = "tracing")] @@ -468,6 +469,7 @@ pub fn window_event_listener_untyped( cb.unchecked_ref(), ); let event_name = event_name.to_string(); + let cb = SendWrapper::new(cb); WindowListenerHandle(Box::new(move || { _ = window().remove_event_listener_with_callback( &event_name, @@ -511,7 +513,7 @@ where } /// A handle that can be called to remove a global event listener. -pub struct WindowListenerHandle(Box); +pub struct WindowListenerHandle(Box); impl core::fmt::Debug for WindowListenerHandle { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {