pip_services3_commons.commands.Event module
pip_services3_commons.commands.Event
Event implementation
- copyright
Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.
- license
MIT, see LICENSE for more details.
-
class
pip_services3_commons.commands.Event.
Event
(name: str) Bases:
pip_services3_commons.commands.IEvent.IEvent
Concrete implementation of
IEvent
interface. It allows to send asynchronous notifications to multiple subscribed listeners.Example:
event_name = Event("my_event") event_name.add_listener(myListener) event_name.notify("123", Parameters.from_tuples("param1", "ABC", "param2", 123)
See
IEvent
,IEventListener
-
add_listener
(listener: pip_services3_commons.commands.IEventListener.IEventListener) Adds a listener to receive notifications when this event_name is fired.
- Parameters
listener – a listener reference to added
-
get_listeners
() → List[pip_services3_commons.commands.IEventListener.IEventListener] Gets all listeners registred in this event_name.
- Returns
a list with listeners
-
notify
(correlation_id: Optional[str, None], args: pip_services3_commons.run.Parameters.Parameters) Fires this event_name and notifies all registred listeners.
- Parameters
correlation_id – (optional) transaction id to trace execution through call chain.
args – the parameters to raise this event_name with.
-
remove_listener
(listener: pip_services3_commons.commands.IEventListener.IEventListener) Removes a listener, so that it no longer receives notifications for this event_name.
- Parameters
listener – a listener reference to removed
-