pub struct EventPublisher<E> { /* private fields */ }Expand description
EventPublisher. Works similarly to C#’s event publishing pattern. Event handling functions are subscribed to the publisher.
Whenever the publisher fires an event it calls all subscribed event handler functions.
Use event::EventPublisher::
Implementations§
Source§impl<E> EventPublisher<E>
impl<E> EventPublisher<E>
Sourcepub fn new() -> EventPublisher<E>
pub fn new() -> EventPublisher<E>
Event publisher constructor.
Sourcepub fn subscribe_handler(&mut self, handler: fn(&Event<E>))
pub fn subscribe_handler(&mut self, handler: fn(&Event<E>))
Subscribes event handler functions to the EventPublisher.
INPUT: handler: fn(&Event
Sourcepub fn unsubscribe_handler(&mut self, handler: fn(&Event<E>)) -> bool
pub fn unsubscribe_handler(&mut self, handler: fn(&Event<E>)) -> bool
Unsubscribes an event handler from the publisher.
INPUT: handler: fn(&Event
Sourcepub fn publish_event(&self, event: &Event<E>)
pub fn publish_event(&self, event: &Event<E>)
Publishes events, pushing the &Event