pub(crate) trait EventTarget<T: Send + Sync> {
// Required methods
fn add_event_listener(
&mut self,
listener: Box<dyn Fn(&T) + Send + Sync + 'static>,
);
fn dispatch_event(&self, message: T);
}
Expand description
A trait that allows adding and dispatching events to listeners.
Required Methods§
Sourcefn add_event_listener(
&mut self,
listener: Box<dyn Fn(&T) + Send + Sync + 'static>,
)
fn add_event_listener( &mut self, listener: Box<dyn Fn(&T) + Send + Sync + 'static>, )
Adds an event listener to the target.
§Arguments
listener
- A function that will be called whenever an event of typeT
occurs.
Sourcefn dispatch_event(&self, message: T)
fn dispatch_event(&self, message: T)
Dispatches an event to all registered listeners.
§Arguments
message
- The event message to be dispatched.