Yahoo! UI Library

event  3.1.0

Yahoo! UI Library > event > SyntheticEvent
Search:
 
Filters

Class SyntheticEvent

Wrapper class for the integration of new events into the YUI event infrastructure. Don't instantiate this object directly, use Y.Event.define( type, config ).

The configuration object must include the event type, and should include implementation methods for on and detach. This is the full list of configuration properties:

type
REQUIRED. The name of the synthetic event. What goes node.on(HERE, callback ).
on
function ( node, subscription, fireEvent ) The implementation logic for subscription. Any special setup you need to do to create the environment for the event being fired. E.g. native DOM event subscriptions. Store subscription related objects and information on the subscription object. When the criteria have been met to fire the synthetic event, call fireEvent.fire().
detach
function ( node, subscription, fireEvent ) The implementation logic for cleaning up a detached subscription. E.g. detach any DOM subscriptions done in on.
publishConfig
(Object) The configuration object that will be used to instantiate the underlying CustomEvent. By default, the event is defined with emitFacade: true so subscribers will receive a DOM-like event object.
processArgs
function ( argArray ) Optional method to extract any additional arguments from the subscription signature. Using this allows on signatures like node.on( "hover", overCallback, outCallback ). Be sure that the args passed in is pruned of any additional arguments using, for example, argArray.splice(2,1);. Data returned from the function will be stored on the subscription object passed to on and detach under subscription._extra.

Constructor

SyntheticEvent ( cfg )
Parameters:
cfg <Object> Implementation pieces and configuration

Methods

_init

protected void _init ( cfg )
Initializes the synthetic event.
Parameters:
cfg <Object> The configuration object passed to the constructor

_processArgs

protected MIXED _processArgs ( args )
Stub implementation. Specify this in the configuration object passed to the constructor (rather, passed to Y.Event.define).
Parameters:
args <Array> Array of arguments passed to on
Returns: MIXED
null by default, but override to return useful data

detach

protected void detach ( type , fn , el )
Initial receiver of the event detach. Passes off control to the implementation detach specified in the constructor configuration after doing the necessary infrastructure cleanup. Note that the implementation function specified in the configuration will be called once for each node passed in el, and each will be a Node instance.
Parameters:
type < String > the synthetic event name
fn <Function> the callback function
el <HTMLElement | Node | HTMLElement[] | NodeList> subscription target(s)

on

protected void on ( type , fn , el )
Initial receiver of the event subscription. Passes off control to the implementation on specified in the constructor configuration after setting up the boiler plate code necessary for clean detaching and destruction in the Event infrastructure. Note that the implementation function specified in the configuration will be called once for each node passed in el, and each will be a Node instance.
Parameters:
type <String> the synthetic event name
fn <Function> the callback function
el <HTMLElement | Node | HTMLElement[] | NodeList> subscription target(s)


Copyright © 2010 Yahoo! Inc. All rights reserved.