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 subscrubed to are fired.

void OnEvent(string correlationId, IEvent event, Parameters args)

  • correlationId: string - a fired evemt
  • event: IEvent - (optional) transaction id to trace execution through call chain.
  • args: Parameters - event arguments.

Examples

public class MyListener: IEventListener {
    private Task onEvent(String correlationId, IEvent event, Parameters args)  {
        Console.WriteLine("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