Struct event::EventPublisher [-]  [+] [src]

pub struct EventPublisher<E> {
    // some fields omitted
}

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::::new() to construct

Methods

impl<E> EventPublisher<E>

fn new() -> EventPublisher<E>

Event publisher constructor.

fn subscribe_handler(&mut self, handler_box: Box<Fn(&Event<E>) + 'static>)

Subscribes event handler functions to the EventPublisher. INPUT: handler_box: Box) + 'static>> handler_box is a box pointer to a function to handle an event of the type E. The function must be capable of handling references to the event type set up by the publisher, rather than the raw event itself. OUTPUT: void

fn unsubscribe_handler(&mut self, handler_box: Box<Fn(&Event<E>) + 'static>) -> bool

Unsubscribes an event handler from the publisher. INPUT: handler_box: Box) + 'static> handler_box is a box pointer to a function to handle an event of the type E. OUTPUT: bool output is a bool of whether or not the function was found in the list of subscribed event handlers and subsequently removed.

fn publish_event(&self, event: &Event<E>)

Publishes events, pushing the &Event to all handler functions stored by the event publisher. INPUT: event: &Event Reference to the Event being pushed to all handling functions.