|Line 37:||Line 37:|
[Edit Descripton] JDispatcher is a class to handle the dispatching of events. Together with the JEvent class, it implements the base funcitonality for the Event-Dispatcher-Pattern.
The Joomla Framework is divided into different tiers (See: Framework). The idea is that business logic and information are encapsulated, so they can be changed, and replaced without affecting other parts of the application. Sometimes however, you need to access information from other parts of the application. The Registry pattern can help you with that (See: JRegistry). And sometimes you want other parts of the application to be automatically informed, once an event anywhere within the application occurs. This is where the Event-Dispatcher-Pattern comes into play.
The pattern allows you to register event-handlers for a certain event at a global event-dispatcher. Once the event occurs, the event-dispatcher calls all event-handlers that handle that certain event and passes a set of arguments to it.
|getInstance||Returns a reference to the global Event Dispatcher object, only creating it if it doesn't already exist.|
|register||Registers an event handler to the event dispatcher|
|trigger||Triggers an event by dispatching arguments to all observers that handle the event and returning their return values.|
jimport( 'joomla.event.dispatcher' );