pub fn on_event(event: String, window_label: Option<&str>, data: Option<String>) {
  let mut l = listeners()
    .lock()
    .expect("Failed to lock listeners: on_event()");

  if l.contains_key(&event) {
    let listeners = l.get_mut(&event).expect("Failed to get mutable handler");
    for handler in listeners {
      if let Some(target_window_label) = window_label {
        // if the emitted event targets a specifid window, only triggers the listeners associated to that window
        if handler.window_label.as_deref() == Some(target_window_label) {
          (handler.on_event)(data.clone())
        }
      } else {
        // otherwise triggers all listeners
        (handler.on_event)(data.clone())
      }
    }
  }
}
/// Triggers the given event with its payload.
Triggers the given event with its payload.
Triggers the given event with its payload .
pub fn on_event(event: String, window_label: Option<&str>, data: Option<String>) {
  let mut l = listeners()
    .lock()
    .expect("Failed to lock listeners: on_event()");
  if l.contains_key(&event) {
    let listeners = l.get_mut(&event).expect("Failed to get mutable handler");
    for handler in listeners {
      if let Some(target_window_label) = window_label {
        // if the emitted event targets a specifid window, only triggers the listeners associated to that window
        if handler.window_label.as_deref() == Some(target_window_label) {
          (handler.on_event)(data.clone())
        }
      } else {
        // otherwise triggers all listeners
        (handler.on_event)(data.clone())
      }
    }
  }
}
pub fn on_event ( event : String , window_label : Option < & str > , data : Option < String > ) { let mut l = listeners ( ) . lock ( ) . expect ( " " ) ; if l . contains_key ( & event ) { let listeners = l . get_mut ( & event ) . expect ( " " ) ; for handler in listeners { if let Some ( target_window_label ) = window_label { // if the emitted event targets a specifid window, only triggers the listeners associated to that window if handler . window_label . as_deref ( ) == Some ( target_window_label ) { ( handler . on_event ) ( data . clone ( ) ) } } else { // otherwise triggers all listeners ( handler . on_event ) ( data . clone ( ) ) } } } }
Triggers the given event with its payload.
Triggers the given event with its payload .
event
String
window_label
Option<&str>
data
Option<String>
event
String
window_label
Option<&str>
data
Option<String>