watson.events.collections¶
- class watson.events.collections.Listener[source]¶
A list of listeners to be used in an EventDispatcher.
A Listener Collection is a list of callbacks that are to be triggered by an event dispatcher. Each item in the list contains the callback, a priority, and whether or not the callback should only be triggered once.
- add(callback, priority=1, only_once=False)[source]¶
Adds a new callback to the collection.
Parameters: - callback (callable) – the function to be triggered
- priority (int) – how important the callback is in relation to others
- only_once (bool) – the callback should only be fired once and then removed
Raises: TypeError if non-callable is added. –
- class watson.events.collections.Result[source]¶
A list of responses from a EventDispatcher.trigger call.
A result collection contains all the resulting output from an event that has been triggered from an event dispatcher. It provides some convenience methods to deal with the results.