Skip to main content

When

Trait When 

Source
pub trait When: AsRef<EventTarget> + Sized {
    // Required method
    fn when<E: FromWasmAbi + 'static, F: FnMut(E) + 'static>(
        self: &Rc<Self>,
        event_type: &'static str,
        callback: F,
    ) -> Result<EventListener<Self, E>, JsError>;
}
Expand description

Trait for listening to events with a callback.

Required Methods§

Source

fn when<E: FromWasmAbi + 'static, F: FnMut(E) + 'static>( self: &Rc<Self>, event_type: &'static str, callback: F, ) -> Result<EventListener<Self, E>, JsError>

Run callback when given event type occurs.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<T> When for T
where T: AsRef<EventTarget>,