Skip to main content

EventCallback

Trait EventCallback 

Source
pub trait EventCallback {
    // Required methods
    fn call(&self, event: &Event);
    fn as_js_value(&self) -> Option<&JsValue>;
}
Expand description

A callback that runs when an event is triggered.

For instance, this might represent the closure in onmyevent = |_| {}.

Required Methods§

Source

fn call(&self, event: &Event)

Invoke the callback.

Source

fn as_js_value(&self) -> Option<&JsValue>

Get the underlying wasm_bindgen::JsValue.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: ?Sized> EventCallback for Closure<T>

Source§

fn call(&self, event: &Event)

Source§

fn as_js_value(&self) -> Option<&JsValue>

Implementors§