Namespace YAHOO.util.CustomEvent
YAHOO.util
The CustomEvent class lets you define events for your application
that can be subscribed to by one or more independent component.
Defined in: event.js.
Constructor Attributes | Constructor Name and Description |
---|---|
The CustomEvent class lets you define events for your application
that can be subscribed to by one or more independent component.
|
Field Attributes | Field Name and Description |
---|---|
<static> |
YAHOO.util.CustomEvent.FLAT
Subscriber listener sigature constant.
|
<static> |
YAHOO.util.CustomEvent.LIST
Subscriber listener sigature constant.
|
The scope the the event will fire from by default.
|
|
Custom events support two styles of arguments provided to the event
subscribers.
|
|
By default all custom events are logged in the debug build, set silent
to true to disable debug outpu for this event.
|
|
The subscribers to this event
|
|
The type of event, returned to subscribers when the event fires
|
Method Attributes | Method Name and Description |
---|---|
<private> |
_delete(index)
|
fire(arguments)
Notifies the subscribers.
|
|
subscribe(fn, obj, override)
Subscribes the caller to this event
|
|
subscribeEvent(fn, obj, override)
Custom events provide a custom event that fires whenever there is
a new subscriber to the event.
|
|
toString()
|
|
unsubscribe(fn, obj)
Unsubscribes the caller from this event
|
|
Removes all listeners
|
Namespace Detail
YAHOO.util.CustomEvent
The CustomEvent class lets you define events for your application
that can be subscribed to by one or more independent component.
- Parameters:
- {String} type
- The type of event, which is passed to the callback when the event fires
- {Object} oScope
- The context the event will fire from. "this" will refer to this object in the callback. Default value: the window object. The listener can override this.
- {boolean} silent
- pass true to prevent the event from writing to the debugsystem
- {int} signature
- the signature that the custom event subscriber will receive. YAHOO.util.CustomEvent.LIST or YAHOO.util.CustomEvent.FLAT. The default is YAHOO.util.CustomEvent.LIST.
Field Detail
<static>
{int}
YAHOO.util.CustomEvent.FLAT
Subscriber listener sigature constant. The FLAT type returns two
parameters: the first argument passed to fire and the optional
custom object
<static>
{int}
YAHOO.util.CustomEvent.LIST
Subscriber listener sigature constant. The LIST type returns three
parameters: the event type, the array of args passed to fire, and
the optional custom object
{object}
scope
The scope the the event will fire from by default. Defaults to the window
obj
{int}
signature
Custom events support two styles of arguments provided to the event
subscribers.
- YAHOO.util.CustomEvent.LIST:
- param1: event name
- param2: array of arguments sent to fire
- param3:
a custom object supplied by the subscriber
- YAHOO.util.CustomEvent.FLAT
- param1: the first argument passed to fire. If you need to pass multiple parameters, use and array or object literal
- param2:
a custom object supplied by the subscriber
{boolean}
silent
By default all custom events are logged in the debug build, set silent
to true to disable debug outpu for this event.
{Subscriber[]}
subscribers
The subscribers to this event
{string}
type
The type of event, returned to subscribers when the event fires
Method Detail
<private>
_delete(index)
- Parameters:
- index
{boolean}
fire(arguments)
Notifies the subscribers. The callback functions will be executed
from the scope specified when the event was created, and with the
following parameters:
- The type of event
- All of the arguments fire() was executed with as an array
- The custom object (if any) that was passed into the subscribe() method
- Parameters:
- {Object*} arguments
- an arbitrary set of parameters to pass to the handler.
- Returns:
- {boolean} false if one of the subscribers returned false, true otherwise
subscribe(fn, obj, override)
Subscribes the caller to this event
- Parameters:
- {Function} fn
- The function to execute
- {Object} obj
- An object to be passed along when the event fires
- {boolean|Object} override
- If true, the obj passed in becomes the execution scope of the listener. if an object, that object becomes the the execution scope.
{YAHOO.util.CustomEvent}
subscribeEvent(fn, obj, override)
Custom events provide a custom event that fires whenever there is
a new subscriber to the event. This provides an opportunity to
handle the case where there is a non-repeating event that has
already fired has a new subscriber.
- Parameters:
- {Function} fn
- The function to execute
- {Object} obj
- An object to be passed along when the event fires
- {boolean|Object} override
- If true, the obj passed in becomes the execution scope of the listener. if an object, that object becomes the the execution scope.
toString()
{boolean}
unsubscribe(fn, obj)
Unsubscribes the caller from this event
- Parameters:
- {Function} fn
- The function to execute
- {Object} obj
- The custom object passed to subscribe (optional)
- Returns:
- {boolean} True if the subscriber was found and detached.
unsubscribeAll()
Removes all listeners