Class Index | File Index

Classes


Class webdriver.promise.Promise


Defined in: promise.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Represents the eventual value of a completed operation.
Method Summary
Method Attributes Method Name and Description
 
addBoth(callback, opt_self)
Registers a function to be invoked when this promise is either rejected or resolved.
 
addCallback(callback, opt_self)
Registers a function to be invoked when this promise is successfully resolved.
 
addCallbacks(callback, errback, opt_self)
An alias for {@code webdriver.promise.Promise.prototype.then} that permits the scope of the invoked function to be specified.
 
addErrback(errback, opt_self)
Registers a function to be invoked when this promise is rejected.
 
cancel(reason)
Cancels the computation of this promise's value, rejecting the promise in the process.
 
 
then(opt_callback, opt_errback)
Registers listeners for when this instance is resolved.
Class Detail
webdriver.promise.Promise()
Represents the eventual value of a completed operation. Each promise may be in one of three states: pending, resolved, or rejected. Each promise starts in the pending state and may make a single transition to either a fulfilled or failed state.

This class is based on the Promise/A proposal from CommonJS. Additional functions are provided for API compatibility with Dojo Deferred objects.

See:
http://wiki.commonjs.org/wiki/Promises/A
Method Detail
{!webdriver.promise.Promise} addBoth(callback, opt_self)
Registers a function to be invoked when this promise is either rejected or resolved. This function is provided for backwards compatibility with the Dojo Deferred API.
Parameters:
{Function} callback
The function to call when this promise is either resolved or rejected. The function should expect a single argument: the resolved value or rejection error.
{!Object=} opt_self
The object which |this| should refer to when the function is invoked.
Returns:
{!webdriver.promise.Promise} A new promise which will be resolved with the result of the invoked callback.

{!webdriver.promise.Promise} addCallback(callback, opt_self)
Registers a function to be invoked when this promise is successfully resolved. This function is provided for backwards compatibility with the Dojo Deferred API.
Parameters:
{Function} callback
The function to call if this promise is successfully resolved. The function should expect a single argument: the promise's resolved value.
{!Object=} opt_self
The object which |this| should refer to when the function is invoked.
Returns:
{!webdriver.promise.Promise} A new promise which will be resolved with the result of the invoked callback.

{!webdriver.promise.Promise} addCallbacks(callback, errback, opt_self)
An alias for {@code webdriver.promise.Promise.prototype.then} that permits the scope of the invoked function to be specified. This function is provided for backwards compatibility with the Dojo Deferred API.
Parameters:
{Function} callback
The function to call if this promise is successfully resolved. The function should expect a single argument: the promise's resolved value.
{Function} errback
The function to call if this promise is rejected. The function should expect a single argument: the rejection reason.
{!Object=} opt_self
The object which |this| should refer to when the function is invoked.
Returns:
{!webdriver.promise.Promise} A new promise which will be resolved with the result of the invoked callback.

{!webdriver.promise.Promise} addErrback(errback, opt_self)
Registers a function to be invoked when this promise is rejected. This function is provided for backwards compatibility with the Dojo Deferred API.
Parameters:
{Function} errback
The function to call if this promise is rejected. The function should expect a single argument: the rejection reason.
{!Object=} opt_self
The object which |this| should refer to when the function is invoked.
Returns:
{!webdriver.promise.Promise} A new promise which will be resolved with the result of the invoked callback.

cancel(reason)
Cancels the computation of this promise's value, rejecting the promise in the process.
Parameters:
{*} reason
The reason this promise is being cancelled. If not an {@code Error}, one will be created using the value's string representation.

{boolean} isPending()
Returns:
{boolean} Whether this promise's value is still being computed.

{!webdriver.promise.Promise} then(opt_callback, opt_errback)
Registers listeners for when this instance is resolved. This function most overridden by subtypes.
Parameters:
{Function=} opt_callback
The function to call if this promise is successfully resolved. The function should expect a single argument: the promise's resolved value.
{Function=} opt_errback
The function to call if this promise is rejected. The function should expect a single argument: the rejection reason.
Returns:
{!webdriver.promise.Promise} A new promise which will be resolved with the result of the invoked callback.

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