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§
Sourcefn when<E: FromWasmAbi + 'static, F: FnMut(E) + 'static>(
self: &Rc<Self>,
event_type: &'static str,
callback: F,
) -> Result<EventListener<Self, E>, JsError>
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", so this trait is not object safe.