In the subscriber class, you subscribe to an event specifying the event handler that will execute when the event occurs. You also need to write a method to handle the event.

Here is the syntax to subscribe to a class event:

publisher:Event Name :subscribe(handler-method).

Syntax Element

Description

publisher

The class where the event is defined and published.

handler-method

The name of the method that will execute when the event is published.

You can also unsubscribe to an event. Here is the syntax to unsubscribe to a class event:

publisher:Event-Name:unsubscribe.
See also: