pub struct NativeEventHandler { /* private fields */ }Expand description
A wrapper around an event callback.
Stores the event name and a raw pointer to the heap-allocated callback closure.
SAFETY: The inner pointer is allocated via Box::leak and lives for the
entire program. This is safe in single-threaded WASM contexts where no
concurrent access can occur.
Implementations§
Source§impl NativeEventHandler
Implementation of event handler construction, cloning, and invocation.
impl NativeEventHandler
Implementation of event handler construction, cloning, and invocation.
Sourcepub fn new<F>(event_name: NativeEventName, callback: F) -> Selfwhere
F: FnMut(NativeEvent) + 'static,
pub fn new<F>(event_name: NativeEventName, callback: F) -> Selfwhere
F: FnMut(NativeEvent) + 'static,
Sourcepub fn handle(&self, event: NativeEvent)
pub fn handle(&self, event: NativeEvent)
Invokes the underlying callback with the given event.
§Arguments
NativeEvent- The event to pass to the callback.
Trait Implementations§
Source§impl Clone for NativeEventHandler
Clones the event handler, sharing the underlying callback pointer.
impl Clone for NativeEventHandler
Clones the event handler, sharing the underlying callback pointer.
Source§impl Debug for NativeEventHandler
impl Debug for NativeEventHandler
Source§impl From<&NativeEventHandler> for usize
Implementation of From trait for converting &NativeEventHandler into usize address.
impl From<&NativeEventHandler> for usize
Implementation of From trait for converting &NativeEventHandler into usize address.
Source§impl IntoCallbackAttribute for NativeEventHandler
Converts an owned event handler into a callback attribute value.
impl IntoCallbackAttribute for NativeEventHandler
Converts an owned event handler into a callback attribute value.
Re-wraps the handler with a generic “callback” event name so that
subsequent EventAdapter::into_attribute calls can override it with
the correct DOM event type.
Source§fn into_callback_attribute(self) -> AttributeValue
fn into_callback_attribute(self) -> AttributeValue
Converts this event handler into an AttributeValue::Event.
§Returns
AttributeValue- An event attribute value with a generic callback event name.