UNPKG

selenium-webdriver

Version:

The official WebDriver JavaScript bindings from the Selenium project

35 lines 8 kB
<!DOCTYPE html><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"><meta http-equiv="Content-Language" content="en"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>EventEmitter</title><link href="dossier.css" rel="stylesheet" type="text/css"><header><div><form><div><input type="search" placeholder="Search" tabindex="1"></div></form></div></header><main><article><div class="parentlink"><b>Module:</b> <a href="module_selenium-webdriver.html">selenium-webdriver</a></div><div class="codelink"><a href="source/index.js.src.html#l54">View Source</a></div><h1>class EventEmitter</h1><dl><dt>Alias for <code><a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a></code></dl><p>Object that can emit events for others to listen for. This is used instead of Closure&#39;s event system because it is much more light weight. The API is based on Node&#39;s EventEmitters.</p> <h3>new EventEmitter()</h3><div><div class="fn-details"><div><b>Parameters</b></div><dl><dd>None.</dl></div></div><h2>Instance Methods</h2><div id="addListener" class="function"><div><h3>addListener(<wbr>type, listenerFn, opt_scope)<span class="codelink"><a href="source/lib/webdriver/events.js.src.html#l119">code »</a></span></h3><p>Registers a listener.</p> <div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>type<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The type of event to listen for.</p> <dt>listenerFn<code>Function</code><dd><p>The function to invoke when the event is fired.</p> <dt>opt_scope<code>?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>=</code><dd><p>The object in whose scope to invoke the listener.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a></code><dd><p>A self reference.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="emit" class="function"><div><h3>emit(<wbr>type, var_args)<span class="codelink"><a href="source/lib/webdriver/events.js.src.html#l47">code »</a></span></h3><p>Fires an event and calls all listeners.</p> <div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>type<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The type of event to emit.</p> <dt>var_args<code>...*</code><dd><p>Any arguments to pass to each listener.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="listeners" class="function"><div><h3>listeners(<wbr>type)<span class="codelink"><a href="source/lib/webdriver/events.js.src.html#l74">code »</a></span></h3><p>Returns a mutable list of listeners for a specific type of event.</p> <div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>type<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The type of event to retrieve the listeners for.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&lt;{fn: Function, oneshot: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, scope: ?(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)}&gt;</code><dd><p>The registered listeners for the given event type.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="on" class="function"><div><h3>on(<wbr>type, listenerFn, opt_scope)<span class="codelink"><a href="source/lib/webdriver/events.js.src.html#l145">code »</a></span></h3><p>An alias for <code>#addListener()</code>.</p> <div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>type<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The type of event to listen for.</p> <dt>listenerFn<code>Function</code><dd><p>The function to invoke when the event is fired.</p> <dt>opt_scope<code>?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>=</code><dd><p>The object in whose scope to invoke the listener.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a></code><dd><p>A self reference.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="once" class="function"><div><h3>once(<wbr>type, listenerFn, opt_scope)<span class="codelink"><a href="source/lib/webdriver/events.js.src.html#l133">code »</a></span></h3><p>Registers a one-time listener which will be called only the first time an event is emitted, after which it will be removed.</p> <div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>type<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The type of event to listen for.</p> <dt>listenerFn<code>Function</code><dd><p>The function to invoke when the event is fired.</p> <dt>opt_scope<code>?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>=</code><dd><p>The object in whose scope to invoke the listener.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a></code><dd><p>A self reference.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="removeAllListeners" class="function"><div><h3>removeAllListeners(<wbr>opt_type)<span class="codelink"><a href="source/lib/webdriver/events.js.src.html#l176">code »</a></span></h3><p>Removes all listeners for a specific type of event. If no event is specified, all listeners across all types will be removed.</p> <div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>opt_type<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd><p>The type of event to remove listeners from.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a></code><dd><p>A self reference.</p> </dl></div></div></div></div><hr class="fn-sep"><div id="removeListener" class="function"><div><h3>removeListener(<wbr>type, listenerFn)<span class="codelink"><a href="source/lib/webdriver/events.js.src.html#l155">code »</a></span></h3><p>Removes a previously registered event listener.</p> <div><div class="fn-details"><div><b>Parameters</b></div><dl><dt>type<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd><p>The type of event to unregister.</p> <dt>listenerFn<code>Function</code><dd><p>The handler function to remove.</p> </dl></div><div class="fn-details"><div><b>Returns</b></div><dl><dt><code><a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a></code><dd><p>A self reference.</p> </dl></div></div></div></div></article><nav><h3><a href="index.html" tabindex="2">Overview</a></h3><div><input type="checkbox" id="nav-modules" checked/><label for="nav-modules"><h3><span class="selectable" tabindex="2">Modules</span></h3></label><div id="nav-modules-view"></div></div><div><input type="checkbox" id="nav-types" checked/><label for="nav-types"><h3><span class="selectable" tabindex="2">Types</span></h3></label><div id="nav-types-view"></div></div><h3><a href="Changes.html" tabindex="2">Changes</a></h3></nav></main><footer><div><a href="https://github.com/jleyba/js-dossier">Generated by dossier</a></div></footer><script src="types.js"></script><script src="dossier.js"></script>