Reference¶
Event¶
-
class
whistle.
Event
[source]¶ Base class to represent whistle’s events. You can subclass this if you want to embed special data and associated logic with your events, or just let the event dispatcher create instances for you
The event handlers will have
Event
instances passed, so you can bundle any data required by your handlers there.-
propagation_stopped
= False¶ Has the event propagation ended?
-
EventDispatcher¶
-
class
whistle.
EventDispatcher
[source]¶ A logical event dispatcher. All events can only be dispatched in the context of an
EventDispatcher
, and event dispatchers are fully independant and isolated.-
listen
(event_id, priority=0)[source]¶ Decorator that add the decorated functions as one of this instance listeners, for the given event name.
Parameters: - event_id –
- priority –
Returns:
-
remove_listener
(event_id, listener)[source]¶ Remove a fiven listener from this event dispatcher. For now, if the listener is not registered for this event, this method has no effect, but we may raise ValueError in the future if the given listener is not found, you should catch it if you’re not certain the listener is registered.
TODO raise ValueError if not found.
Parameters: - event_id –
- listener –
Returns:
-