Class Events
- class ooodev.events.events.Events(source=None, trigger_args=None)[source]
Bases:
EventsPartial
Basic class for events.
Implements
ooodev.events.events_t.EventsT
protocol.New in version 0.32.0.
- Parameters:
source (Any) –
trigger_args (GenericArgs | None) –
- __init__(source=None, trigger_args=None)[source]
Construct for Events
- Parameters:
source (Any | None, optional) – Source can be class or any object. The value of
source
is the value assigned to theEventArgs.event_source
property. Defaults to current instance of this class.trigger_args (GenericArgs, optional) – Args that are passed to events when they are triggered.
- add_event_observers(*args)
Adds observers that gets their
trigger
method called when this classtrigger
method is called.- Parameters:
args (EventObserver) – One or more observers to add.
- Return type:
None
Note
Observers are removed automatically when they are out of scope.
- remove_event_observer(observer)
Removes an observer
- Parameters:
observer (EventObserver) – One or more observers to add.
- Returns:
True
if observer has been removed; Otherwise,False
.- Return type:
bool
- subscribe_event(event_name, callback)
Add an event listener to current instance.
- Parameters:
event_name (str) – Event Name.
callback (EventCallback) – Callback of the event listener.
- Return type:
None
- trigger_event(event_name, event_args)
Trigger an event on current instance.
- Parameters:
event_name (str) – Event Name.
event_args (EventArgsT) – Event Args.
- Return type:
None
- unsubscribe_event(event_name, callback)
Remove an event listener from current instance.
- Parameters:
event_name (str) – Event Name.
callback (EventCallback) – Callback of the event listener.
- Return type:
None
- property event_observer: EventObserver
Gets/Sets The Event Observer for this instance.
- Return type: