1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <title>API: event YAHOO.util.EventProvider (YUI Library)
</title>
5 <link rel=
"stylesheet" type=
"text/css" href=
"assets/api.css">
9 <div id=
"doc3" class=
"yui-t2">
12 <h1>Yahoo! UI Library
</h1>
13 <h3>Event Utility
<span class=
"subtitle">2.2.0</span></h3>
15 <a href=
"./index.html">Yahoo! UI Library
</a>
16 > <a href=
"./module_event.html">event
</a>
17 > YAHOO.util.EventProvider
32 Class
<b>YAHOO.util.EventProvider
</b>
33 <span class=
"extends">
36 <span class=
"extends">
41 <!-- class tree goes here -->
46 <div class=
"summary description">
47 EventProvider is designed to be used with YAHOO.augment to wrap
48 CustomEvents in an interface that allows events to be subscribed to
49 and fired by name. This makes it possible for implementing code to
50 subscribe to an event that either has not been created yet, or will
51 not be created at all.
55 <div class=
"section field details">
56 <h3><a name=
"field_detail">Properties
</a></h3>
58 <h4><a name=
"__yui_events">__yui_events
</a>
59 <code>- private Object[]
</code>
62 <div class=
"description">
63 Private storage of custom events
71 <h4><a name=
"__yui_subscribers">__yui_subscribers
</a>
72 <code>- private Object[]
</code>
75 <div class=
"description">
76 Private storage of custom event subscribers
90 <div class=
"section method details">
91 <h3><a name=
"methodDetails">Methods
</a></h3>
94 <a name=
"createEvent">createEvent
</a></h4>
101 <strong>createEvent
</strong>
115 <div class=
"description">
116 Creates a new custom event of the specified type. If a custom event
117 by that name already exists, it will not be re-created. In either
118 case the custom event is returned.
121 <div class=
"description">
126 <code>p_type
<string
></code>
127 the type, or name of the event
130 <code>p_config
<object
></code>
131 optional config params. Valid properties are:
134 scope: defines the default execution scope. If not defined
135 the default scope will be this instance.
138 silent: if true, the custom event will not generate log messages.
139 This is false by default.
142 onSubscribeCallback: specifies a callback to execute when the
143 event has a new subscriber. This will fire immediately for
144 each queued subscriber if any exist prior to the creation of
156 <dd>the custom event
</dd>
164 <a name=
"fireEvent">fireEvent
</a></h4>
171 <strong>fireEvent
</strong>
185 <div class=
"description">
186 Fire a custom event by name. The callback functions will be executed
187 from the scope specified when the event was created, and with the
188 following parameters:
190 <li>The first argument fire() was executed with
</li>
191 <li>The custom object (if any) that was passed into the subscribe()
196 <div class=
"description">
201 <code>p_type
<string
></code>
202 the type, or name of the event
205 <code>arguments
<Object*
></code>
206 an arbitrary set of parameters to pass to
216 <dd>the return value from CustomEvent.fire, or null if
217 the custom event does not exist.
</dd>
225 <a name=
"hasEvent">hasEvent
</a></h4>
232 <strong>hasEvent
</strong>
242 <div class=
"description">
243 Returns true if the custom event of the provided type has been created
247 <div class=
"description">
252 <code>type
<string
></code>
253 the type, or name of the event
270 <a name=
"subscribe">subscribe
</a></h4>
277 <strong>subscribe
</strong>
301 <div class=
"description">
302 Subscribe to a CustomEvent by event type
305 <div class=
"description">
310 <code>p_type
<string
></code>
311 the type, or name of the event
314 <code>p_fn
<function
></code>
315 the function to exectute when the event fires
318 <code>p_obj
<object
></code>
322 <code>p_obj
<Object
></code>
323 An object to be passed along when the event
327 <code>p_override
<boolean
></code>
328 If true, the obj passed in becomes the
329 execution scope of the listener
346 <a name=
"unsubscribe">unsubscribe
</a></h4>
353 <strong>unsubscribe
</strong>
371 <div class=
"description">
372 Unsubscribes one or more listeners the from the specified event
375 <div class=
"description">
380 <code>p_type
<string
></code>
381 The type, or name of the event
384 <code>p_fn
<Function
></code>
385 The subscribed function to unsubscribe, if not
386 supplied, all subscribers will be removed.
389 <code>p_obj
<Object
></code>
390 The custom object passed to subscribe. This is
391 optional, but if supplied will be used to
392 disambiguate multiple listeners that are the same
393 (e.g., you subscribe many object using a function
394 that lives on the prototype)
403 <dd>true if the subscriber was found and detached.
</dd>
411 <a name=
"unsubscribeAll">unsubscribeAll
</a></h4>
418 <strong>unsubscribeAll
</strong>
428 <div class=
"description">
429 Removes all listeners from the specified event
432 <div class=
"description">
437 <code>p_type
<string
></code>
438 The type, or name of the event
472 <li class=
""><a href=
"module_animation.html">animation
</a></li>
474 <li class=
""><a href=
"module_autocomplete.html">autocomplete
</a></li>
476 <li class=
""><a href=
"module_button.html">button
</a></li>
478 <li class=
""><a href=
"module_calendar.html">calendar
</a></li>
480 <li class=
""><a href=
"module_connection.html">connection
</a></li>
482 <li class=
""><a href=
"module_container.html">container
</a></li>
484 <li class=
""><a href=
"module_datasource.html">datasource
</a></li>
486 <li class=
""><a href=
"module_datatable.html">datatable
</a></li>
488 <li class=
""><a href=
"module_dom.html">dom
</a></li>
490 <li class=
""><a href=
"module_dragdrop.html">dragdrop
</a></li>
492 <li class=
""><a href=
"module_element.html">element
</a></li>
494 <li class=
"selected"><a href=
"module_event.html">event
</a></li>
496 <li class=
""><a href=
"module_history.html">history
</a></li>
498 <li class=
""><a href=
"module_logger.html">logger
</a></li>
500 <li class=
""><a href=
"module_menu.html">menu
</a></li>
502 <li class=
""><a href=
"module_slider.html">slider
</a></li>
504 <li class=
""><a href=
"module_tabview.html">tabview
</a></li>
506 <li class=
""><a href=
"module_treeview.html">treeview
</a></li>
508 <li class=
""><a href=
"module_yahoo.html">yahoo
</a></li>
515 <li class=
""><a href=
"YAHOO.util.CustomEvent.html">YAHOO.util.CustomEvent
</a></li>
516 <li class=
""><a href=
"YAHOO.util.Event.html">YAHOO.util.Event
</a></li>
517 <li class=
"selected"><a href=
"YAHOO.util.EventProvider.html">YAHOO.util.EventProvider
</a></li>
518 <li class=
""><a href=
"YAHOO.util.Subscriber.html">YAHOO.util.Subscriber
</a></li>
525 <li class=
""><a href=
"CustomEvent.js.html">CustomEvent.js
</a></li>
526 <li class=
""><a href=
"Event.js.html">Event.js
</a></li>
527 <li class=
""><a href=
"EventProvider.js.html">EventProvider.js
</a></li>
534 <li><a href=
"#__yui_events">__yui_events
</a>
535 <!--<code><Object[]></code>-->
537 <li><a href=
"#__yui_subscribers">__yui_subscribers
</a>
538 <!--<code><Object[]></code>-->
546 <li><!--<code>CustomEvent</code>-->
547 <a href=
"#createEvent">createEvent
</a>
549 <li><!--<code>boolean</code>-->
550 <a href=
"#fireEvent">fireEvent
</a>
552 <li><!--<code>void</code>-->
553 <a href=
"#hasEvent">hasEvent
</a>
555 <li><!--<code>void</code>-->
556 <a href=
"#subscribe">subscribe
</a>
558 <li><!--<code>boolean</code>-->
559 <a href=
"#unsubscribe">unsubscribe
</a>
561 <li><!--<code>void</code>-->
562 <a href=
"#unsubscribeAll">unsubscribeAll
</a>
574 Copyright
© 2007 Yahoo! Inc. All rights reserved.