Name

LzDelegate — The receiver in Laszlo's point-to-point event system.

Synopsis

JavaScript: LzDelegate
Type: Class
Access: public
Topic: LFC.Events
Declared in: WEB-INF/lps/lfc/events/LaszloEvents.lzs

Description

A delegate is an object that calls a specific method in a specific context when its execute method is called. It is essentially a function pointer.

Delegates, along with LzEvent, comprise Laszlo's point to point event system. A delegate represents a named method of an instance. Delegates are mostly registered with events, but they can be used anywhere a function callback would traditionally be called for: for instance, the LzTimer service takes a delegate as its argument when a timer is started. See the code example on the LzEvent.

Superclass Chain

LzDelegate

Known Subclasses

Details

Properties (5)

c
public var c : Object;
The context in which to call the method
enabled
public var enabled = true;
event_called
public var event_called = false;
f
public var f : String;
The name of the method to call
lastevent
public var lastevent = 0.0;

Methods (7)

disable()
public function disable();
Disables the delegate until enable method is called.
enable()
public function enable();
Enables a delegate that has been disabled
execute()
protected function execute(sd);
Executes the named method in the given context with the given data. Returns the result of the call. In rare cases, this method may be overriden by a subclass, and so it is marked 'protected' instead of 'private'.
initialize()
public function initialize(context : Object, functionName : String, eventSender : Object, eventName : String);
register()
public function register(eventSender : Object, eventName : String);
Registers the delegate for the named event in the given context. NB: This is the primary way in which events are created. Published events do not generally exist as objects (with some exceptions) until delegates are created for them.
unregisterAll()
public function unregisterAll();
Unregisters the delegate for all of the events it is registered for.
unregisterFrom()
public function unregisterFrom(event : LzEvent);
Unregisters the delegate for the given event

JavaScript Synopsis

public LzDelegate {
  public var c  : Object;
  public var enabled  = true;
  public var event_called  = false;
  public var f  : String;
  public var lastevent  = 0.0;
  prototype public function disable ();
  prototype public function enable ();
  prototype protected function execute (sd);
  prototype public function initialize (context : Object, functionName : String, eventSender : Object, eventName : String);
  prototype public function register (eventSender : Object, eventName : String);
  prototype public function unregisterAll ();
  prototype public function unregisterFrom (event : LzEvent);
}