# Class webdriver.EventEmitter

code »

Object that can emit events for others to listen for. This is used instead of Closure's event system because it is much more light weight. The API is based on Node's EventEmitters.

## Constructor

webdriver.EventEmitter ( )
Show:Public Protected Private

## Instance Methods

code »addListener ( type, listenerFn, opt_scope ) ⇒ `!webdriver.EventEmitter`

Registers a listener.

Parameters
type: `string` The type of event to listen for. listenerFn: `!Function` The function to invoke when the event is fired. opt_scope: `Object=` The object in whose scope to invoke the listener.
Returns
A self reference.

code »addListener_ ( type, listenerFn, opt_scope, opt_oneshot ) ⇒ `!webdriver.EventEmitter`

Registers a listener.

Parameters
type: `string` The type of event to listen for. listenerFn: `!Function` The function to invoke when the event is fired. opt_scope: `Object=` The object in whose scope to invoke the listener. opt_oneshot: `boolean=` Whether the listener should be removed after the first event is fired.
Returns
A self reference.

code »emit ( type, var_args )

Fires an event and calls all listeners.

Parameters
type: `string` The type of event to emit. var_args: `...*` Any arguments to pass to each listener.

code »listeners ( type ) ⇒ `!Array`

Returns a mutable list of listeners for a specific type of event.

Parameters
type: `string` The type of event to retrieve the listeners for.
Returns
The registered listeners for the given event type.

code »on ( type, listenerFn, opt_scope ) ⇒ `!webdriver.EventEmitter`

An alias for `#addListener()`.

Parameters
type: `string` The type of event to listen for. listenerFn: `!Function` The function to invoke when the event is fired. opt_scope: `Object=` The object in whose scope to invoke the listener.
Returns
A self reference.

code »once ( type, listenerFn, opt_scope ) ⇒ `!webdriver.EventEmitter`

Registers a one-time listener which will be called only the first time an event is emitted, after which it will be removed.

Parameters
type: `string` The type of event to listen for. listenerFn: `!Function` The function to invoke when the event is fired. opt_scope: `Object=` The object in whose scope to invoke the listener.
Returns
A self reference.

code »removeAllListeners ( opt_type ) ⇒ `!webdriver.EventEmitter`

Removes all listeners for a specific type of event. If no event is specified, all listeners across all types will be removed.

Parameters
opt_type: `string=` The type of event to remove listeners from.
Returns
A self reference.

code »removeListener ( type, listenerFn ) ⇒ `!webdriver.EventEmitter`

Removes a previously registered event listener.

Parameters
type: `string` The type of event to unregister. listenerFn: `!Function` The handler function to remove.
Returns
A self reference.

## Instance Properties

code »events_ : `!Object`

Map of events to registered listeners.