pub struct EventBus { /* private fields */ }Expand description
Synchronous event bus: stores handlers keyed by EventKind and a history of all
published events.
Implementations§
Source§impl EventBus
impl EventBus
Sourcepub fn subscribe(&mut self, kind: EventKind, handler: EventHandler)
pub fn subscribe(&mut self, kind: EventKind, handler: EventHandler)
Register a handler for a specific event kind.
Sourcepub fn publish(&mut self, event: Event)
pub fn publish(&mut self, event: Event)
Publish an event: invoke matching handlers then append to history.
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear the event history.
Sourcepub fn handler_count(&self) -> usize
pub fn handler_count(&self) -> usize
Total number of registered handlers.
Sourcepub fn event_count(&self) -> usize
pub fn event_count(&self) -> usize
Total number of events published so far.
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