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

onEvent

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

void onEvent(IContext context, IEvent event, Parameters args)

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

Examples

 {
   public class MyListener implements IEventListener {
      private void onEvent(IContext context, IEvent event,Parameters args) {
        System.out.println("Fired event " + event.getName());
      }
   }
 
   Event event = new Event("myevent");
   event.addListener(new MyListener());
   event.notify("123", Parameters.fromTuples("param1", "ABC"));
 
   // Console output: Fired event myevent
  }

See also