IEventListener

An interface for listener objects that receive notifications on fired events.

Description

The IEventListener interface allows you to define actions to be taken by listener objects after receiving a notification on a fired event.

Instance methods

on_event

A method called when events this listener is subscrubed to are fired.

on_event(context: Optional[IContext], event: IEvent, args: Parameters)

  • context: IContext - (optional) a context to trace execution through a call chain
  • event: IEvent - (optional) transaction id to trace execution through call chain.
  • args: Parameters - event arguments.

Examples

class MyListener(IEventListener):
    def on_event(self, context, event_name, args):
        print "Fired event_name " + event_name.get_name()
     
event = Event("myevent")
event.addListener(MyListener())
event.notify("123", Parameters.from_tuples("param1", "ABC"))

See also