pub struct EventBus { /* private fields */ }Expand description
Sync event bus: listeners run in the dispatching task (order of registration).
Implementations§
Source§impl EventBus
impl EventBus
pub fn new() -> Self
Sourcepub fn listen<E, F>(&self, f: F)
pub fn listen<E, F>(&self, f: F)
Register a typed listener. Multiple listeners per event type are allowed.
Sourcepub fn dispatch<E: Event>(&self, event: E)
pub fn dispatch<E: Event>(&self, event: E)
Dispatch event to all listeners for E (registration order).
Sourcepub fn listener_count<E: Event>(&self) -> usize
pub fn listener_count<E: Event>(&self) -> usize
Number of listeners registered for E (tests / diagnostics).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EventBus
impl RefUnwindSafe for EventBus
impl Send for EventBus
impl Sync for EventBus
impl Unpin for EventBus
impl UnsafeUnpin for EventBus
impl UnwindSafe for EventBus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more