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

Static Properties (2)

__LZdelegatesQueue
static private var __LZdelegatesQueue;
Queue for delegates that are deferred during node initialization
__nextID
static private var __nextID = 1;

Static Methods (1)

__LZdrainDelegatesQueue()
static private function __LZdrainDelegatesQueue(pos);
Drain the delegates queue back to position POS

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 (9)

_dbg_name()
private function _dbg_name();
If debugging, add an informative name
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.
toString()
private function toString();
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 {
  static private var __LZdelegatesQueue ;
  static private function __LZdrainDelegatesQueue (pos);
  static private var __nextID  = 1;
  public var c  : Object;
  public var enabled  = true;
  public var event_called  = false;
  public var f  : String;
  public var lastevent  = 0.0;
  prototype private function _dbg_name ();
  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 private function toString ();
  prototype public function unregisterAll ();
  prototype public function unregisterFrom (event : LzEvent);
}