whistle.dispatchers¶
- class AsyncEventDispatcher[source]¶
Bases:
AbstractEventDispatcherAdapts whiste’s EventDispatcher to be async.
Added in version 2.0.
- class EventDispatcher[source]¶
Bases:
AbstractEventDispatcherMain class of the library, it is responsible for keeping track of registered listeners, and dispatching events to them. All listeners are scoped to the event dispatcher instance, so you can have multiple event dispatchers with different sets of listeners.
- dispatch(event_id, event=None, /)[source]¶
Dispatch the given event, with the given event id.
An optional event can be given, and should respect the
whistle.protocols.IEventprotocol. If no event is given, a newwhistle.event.Eventinstance is created and used.Returns the event instance after it has been dispatched, whether it has been created or provided by the caller.
- Parameters:
- Returns:
the event instance after it has been dispatched
- Return type: