Class Index | File Index

Classes


Class webdriver.promise.Deferred


Extends .

Defined in: promise.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
webdriver.promise.Deferred(opt_canceller, opt_flow)
Represents a value that will be resolved at some point in the future.
Field Summary
Field Attributes Field Name and Description
<inner>  
Whether this Deferred's resolution was ever handled by a listener.
<inner>  
The listeners registered with this Deferred.
<inner>  
Key for the timeout used to delay reproting an unhandled rejection to the parent webdriver.promise.ControlFlow.
<inner>  
The consumer promise for this instance.
<inner>  
This Deferred's current state.
<inner>  
This Deferred's resolved value; set when the state transitions from {@code webdriver.promise.Deferred.State_.PENDING}.
Method Summary
Method Attributes Method Name and Description
<inner>  
cancel(opt_reason)
Attempts to cancel the computation of this instance's value.
<inner>  
fulfill(opt_value)
Resolves this promise with the given value.
<inner>  
<inner>  
notify(listener)
Notifies a single listener of this Deferred's change in state.
<inner>  
notifyAll(newState, newValue)
Notifies all of the listeners registered with this Deferred that its state has changed.
<inner>  
Propagates an unhandled rejection to the parent ControlFlow in a future turn of the JavaScript event loop.
<inner>  
reject(opt_error)
Rejects this promise.
<inner>  
Removes all of the listeners previously registered on this deferred.
<inner>  
then(opt_callback, opt_errback)
Registers a callback on this Deferred.
Class Detail
webdriver.promise.Deferred(opt_canceller, opt_flow)
Represents a value that will be resolved at some point in the future. This class represents the protected "producer" half of a Promise - each Deferred has a {@code promise} property that may be returned to consumers for registering callbacks, reserving the ability to resolve the deferred to the producer.

If this Deferred is rejected and there are no listeners registered before the next turn of the event loop, the rejection will be passed to the webdriver.promise.ControlFlow as an unhandled failure.

If this Deferred is cancelled, the cancellation reason will be forward to the Deferred's canceller function (if provided). The canceller may return a truth-y value to override the reason provided for rejection.

Parameters:
{Function=} opt_canceller
Function to call when cancelling the computation of this instance's value.
{webdriver.promise.ControlFlow=} opt_flow
The control flow this instance was created under. This should only be provided during unit tests.
Field Detail
<inner> handled
Whether this Deferred's resolution was ever handled by a listener. If the Deferred is rejected and its value is not handled by a listener before the next turn of the event loop, the error will be passed to the global error handler.

<inner> listeners
The listeners registered with this Deferred. Each element in the list will be a 3-tuple of the callback function, errback function, and the corresponding deferred object.

<inner> pendingRejectionKey
Key for the timeout used to delay reproting an unhandled rejection to the parent webdriver.promise.ControlFlow.

<inner> promise
The consumer promise for this instance. Provides protected access to the callback registering functions.

<inner> state
This Deferred's current state.

<inner> value
This Deferred's resolved value; set when the state transitions from {@code webdriver.promise.Deferred.State_.PENDING}.
Method Detail
<inner> cancel(opt_reason)
Attempts to cancel the computation of this instance's value. This attempt will silently fail if this instance has already resolved.
Parameters:
{*=} opt_reason
The reason for cancelling this promise.

<inner> fulfill(opt_value)
Resolves this promise with the given value. If the value is itself a promise and not a reference to this deferred, this instance will wait for it before resolving.
Parameters:
{*=} opt_value
The resolved value.

<inner> {boolean} isPending()
Returns:
{boolean} Whether this promise's value is still pending.

<inner> notify(listener)
Notifies a single listener of this Deferred's change in state.
Parameters:
{!webdriver.promise.Deferred.Listener_} listener
The listener to notify.

<inner> notifyAll(newState, newValue)
Notifies all of the listeners registered with this Deferred that its state has changed. Will throw an error if this Deferred has already been resolved.
Parameters:
{!webdriver.promise.Deferred.State_} newState
The deferred's new state.
{*} newValue
The deferred's new value.

<inner> {number} propagateError(error)
Propagates an unhandled rejection to the parent ControlFlow in a future turn of the JavaScript event loop.
Parameters:
{*} error
The error value to report.
Returns:
{number} The key for the registered timeout.

<inner> reject(opt_error)
Rejects this promise. If the error is itself a promise, this instance will be chained to it and be rejected with the error's resolved value.
Parameters:
{*=} opt_error
The rejection reason, typically either a {@code Error} or a {@code string}.

<inner> removeAll()
Removes all of the listeners previously registered on this deferred.
Throws:
{Error}
If this deferred has already been resolved.

<inner> {!webdriver.promise.Promise} then(opt_callback, opt_errback)
Registers a callback on this Deferred.
Parameters:
{Function=} opt_callback
The callback.
{Function=} opt_errback
The errback.
Returns:
{!webdriver.promise.Promise} A new promise representing the result of the callback.
See:
webdriver.promise.Promise#then

Documentation generated by JsDoc Toolkit 2.4.0 on Sat Jan 25 2014 14:42:02 GMT-0500 (EST)