Try OpenEdge Now
skip to main content
Object-oriented Programming
Object-oriented Programming and ABL : Overview of class-based ABL : Publishing and responding to class events
 

Publishing and responding to class events

You can publish a class event using the built-in Publish( ) event method from within the class that defines the event (see the ). The event definition cannot be abstract. When you invoke this method for a given class event, it executes any and all event handlers that you previously subscribed to the event. You also pass any parameters to this method that you defined for the event, and they get passed to each event handler that executes. The method returns any results to the caller.
Caution: Parameter passing for multiple event handlers requires careful design, as results are returned only from the last event handler to execute, and some parameter results can be passed from one event handler to the next. For more information, see Publishing class events.
You can subscribe an event handler to an event using the built-in Subscribe( ) event method. An event to which you subscribe an event handler can be defined as abstract. The subscription then applies to the class in the hierarchy where the event is actually implemented. The access mode of an event determines where you can execute the Subscribe( ) method on the event, whether inside or outside the class or class hierarchy where the event is defined. In any case, you can subscribe any accessible method or internal procedure with a compatible signature as a handler for the event, even if the method or internal procedure is not accessible to the publishing class. Using the built-in Unsubscribe( ) event method, you can also remove a method or internal procedure as an event handler for the event, again, depending on the access mode of the event.
For more information on publishing and responding to class events, see Publishing and subscribing to class events.
* Comparison with procedure-based programming