pub fn listen<F: FnMut(Option<String>) + Send + 'static>(
  id: impl AsRef<str>,
  window_label: Option<String>,
  handler: F,
) {
  let mut l = listeners()
    .lock()
    .expect("Failed to lock listeners: listen()");
  let handler = EventHandler {
    window_label,
    on_event: Box::new(handler),
  };
  if let Some(listeners) = l.get_mut(id.as_ref()) {
    listeners.push(handler);
  } else {
    l.insert(id.as_ref().to_string(), vec![handler]);
  }
}
/// Adds an event listener for JS events.
Adds an event listener for JS events.
Adds an event listener for JS events .
pub fn listen<F: FnMut(Option<String>) + Send + 'static>(
  id: impl AsRef<str>,
  window_label: Option<String>,
  handler: F,
) {
  let mut l = listeners()
    .lock()
    .expect("Failed to lock listeners: listen()");
  let handler = EventHandler {
    window_label,
    on_event: Box::new(handler),
  };
  if let Some(listeners) = l.get_mut(id.as_ref()) {
    listeners.push(handler);
  } else {
    l.insert(id.as_ref().to_string(), vec![handler]);
  }
}
pub fn listen < F : FnMut ( Option < String > ) + Send + ' static > ( id : impl AsRef < str > , window_label : Option < String > , handler : F , ) { let mut l = listeners ( ) . lock ( ) . expect ( " " ) ; let handler = EventHandler { window_label , on_event : Box :: new ( handler ) , } ; if let Some ( listeners ) = l . get_mut ( id . as_ref ( ) ) { listeners . push ( handler ) ; } else { l . insert ( id . as_ref ( ) . to_string ( ) , vec ! [ handler ] ) ; } }
Adds an event listener for JS events.
Adds an event listener for JS events .
id
impl AsRef<str>
window_label
Option<String>
handler
F
id
impl AsRef<str>
window_label
Option<String>
handler
F