dlab_core.dispatchers

Module Contents

exception DispatcherExpectedCallableException[source]

Bases: dlab_core.domain.exceptions.DLabException

Raised when trying to call non callable object.

class EventDispatcher[source]
add_listener(self, name, call)[source]

Adds an event listener that listens on the specified events.

Parameters:
  • name (str) – The name of the event to dispatch.
  • call (callable) – The passed callable.

:raise DispatcherExpectedCallableException

get_listeners(self, name)[source]

Gets the list of listeners for a specific event.

Parameters:name (str) – The name of the event to dispatch.

:rtype set :return: List of all event listeners selected by event name.

has_listeners(self, name)[source]

Checks whether an event has any registered listeners.

Parameters:name (str) – The name of the event to dispatch.
Return type:bool
Returns:True if the specified event has any listeners,

False otherwise.

dispatch(self, name)[source]

Dispatches an event to all registered listeners.

Parameters:name (str) – The name of the event to dispatch.