cf2:EventTarget

Purpose

This component allows different elements of the Client Framework 2 to communicate with each other. It contains a set of registered handlers. Events can be dispatched to these handlers. Each handler is identified by the type of events it applies to, the function and the optional array of additional arguments, and can only be registered once. The same function can be registered for different types of events or different arguments.

Exported Features

cf2:EventTarget

Imported Features

n/a

JavaScript

This component is provided by the V$.cf2.EventTarget mixin class that has the following methods.

evtFire(event)

Fires the specified event invoking the registered event handlers and passing in the supplied event. It is an error if the supplied event does not contain, as a minimum, the common event properties defined in The following table. Only those event handlers which did not specify the event type, or which event type matches the type in the passed in event will be invoked.

Firing events may result in additional event handlers being registered, or existing event handlers being removed. If additional event handlers are added, then they are not invoked until the next event is fired. Removing an event handler does not prevent it from being called for the current event even if it has not yet been invoked at the time it was removed.

Parameter Description Type
event Specifies the event to pass to the event handlers. Event
boolean evtRegister(function, type?)

Registers the event handler. Returns true if the event handler was added, or false if it was already on the list of handlers.

Parameter Description Type
function The event handler function to register. Function
type The type of the event that the handler is interested in. If not specified, then the handler will be called for all events. String
boolean evtDeregister(function, type?)

Deregisters the previously registered event handler. Returns true if the event handler was removed, or false if it was not on the list of handlers.

Parameter Description Type
function The function with which the event handler was registered. Function
type The type of the event with which the handler was registered. String

Common event properties

The following table lists the common event properties.

Property Description Type
type The type of the event. String
target The target of the event, usually the object upon which the evtFire() method was invoked. any

Related topics