Struct bee_runtime::event::Bus
source · [−]pub struct Bus<'a, ID = TypeId> { /* private fields */ }
Expand description
An event bus for arbitrary event types.
Implementations
sourceimpl<'a, ID: Clone + PartialEq> Bus<'a, ID>
impl<'a, ID: Clone + PartialEq> Bus<'a, ID>
sourcepub fn dispatch<E: Any>(&self, event: E)
pub fn dispatch<E: Any>(&self, event: E)
Dispatch an event via this event bus.
All active listeners registered for this event will be invoked.
sourcepub fn add_listener_raw<E: Any, F: Fn(&E) + Send + Sync + 'a>(
&self,
id: ID,
handler: F
)
pub fn add_listener_raw<E: Any, F: Fn(&E) + Send + Sync + 'a>(
&self,
id: ID,
handler: F
)
Add an event listener bound to a specific event type, E
, and registered with the given ID.
sourcepub fn remove_listeners_by_id(&self, id: ID)
pub fn remove_listeners_by_id(&self, id: ID)
Remove all event listeners registered with the given ID, dropping them in the process.
sourceimpl<'a> Bus<'a, TypeId>
impl<'a> Bus<'a, TypeId>
sourcepub fn add_listener<T: Any, E: Any, F: Fn(&E) + Send + Sync + 'a>(
&self,
handler: F
)
pub fn add_listener<T: Any, E: Any, F: Fn(&E) + Send + Sync + 'a>(
&self,
handler: F
)
Add an event listener bound to a specific event type, E
, and bound to a type T
.
This event listener will be removed when Bus::remove_listeners_by_id
is called with the TypeId
of T
.
Trait Implementations
Auto Trait Implementations
impl<'a, ID = TypeId> !RefUnwindSafe for Bus<'a, ID>
impl<'a, ID> Send for Bus<'a, ID>where
ID: Send,
impl<'a, ID> Sync for Bus<'a, ID>where
ID: Send + Sync,
impl<'a, ID> Unpin for Bus<'a, ID>
impl<'a, ID = TypeId> !UnwindSafe for Bus<'a, ID>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more