Struct event::EventPublisher [] [src]

pub struct EventPublisher<E> { /* 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>
[src]

Event publisher constructor.

Subscribes event handler functions to the EventPublisher. INPUT: handler: fn(&Event) handler is a 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

Unsubscribes an event handler from the publisher. INPUT: handler: fn(&Event) handler is a 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.

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.