Interface webdriver.promise.Thenable.<T>
code »Thenable is a promise-like object with a then
method which may be
used to schedule callbacks on a promised value.
Instance Methods
Cancels the computation of this promise's value, rejecting the promise in the
process. This method is a no-op if the promise has alreayd been resolved.
Parameters |
---|
|
Registers listeners for when this instance is resolved.
Parameters |
---|
|
Returns |
|
Registers a listener for when this promise is rejected. This is synonymous
with the catch
clause in a synchronous API:
// Synchronous API:
try {
doSynchronousWork();
} catch (ex) {
console.error(ex);
}
// Asynchronous promise API:
doAsynchronousWork().thenCatch(function(ex) {
console.error(ex);
});
catch
clause in a synchronous API:
// Synchronous API:
try {
doSynchronousWork();
} catch (ex) {
console.error(ex);
}
// Asynchronous promise API:
doAsynchronousWork().thenCatch(function(ex) {
console.error(ex);
});
Parameters |
---|
|
Returns |
|
Registers a listener to invoke when this promise is resolved, regardless
of whether the promise's value was successfully computed. This function
is synonymous with the finally
clause in a synchronous API:
// Synchronous API:
try {
doSynchronousWork();
} finally {
cleanUp();
}
// Asynchronous promise API:
doAsynchronousWork().thenFinally(cleanUp);
Note: similar to the finally
clause, if the registered
callback returns a rejected promise or throws an error, it will silently
replace the rejection error (if any) from this promise:
try {
throw Error('one');
} finally {
throw Error('two'); // Hides Error: one
}
webdriver.promise.rejected(Error('one'))
.thenFinally(function() {
throw Error('two'); // Hides Error: one
});
finally
clause in a synchronous API:
// Synchronous API:
try {
doSynchronousWork();
} finally {
cleanUp();
}
// Asynchronous promise API:
doAsynchronousWork().thenFinally(cleanUp);
try {
throw Error('one');
} finally {
throw Error('two'); // Hides Error: one
}
webdriver.promise.rejected(Error('one'))
.thenFinally(function() {
throw Error('two'); // Hides Error: one
});
Parameters |
---|
|
Returns |
|
Global Functions
Adds a property to a class prototype to allow runtime checks of whether
instances of that class implement the Thenable interface. This function will
also ensure the prototype's then
function is exported from compiled
code.
then
function is exported from compiled
code.Parameters |
---|
|
code »webdriver.promise.Thenable.isImplementation ( object ) ⇒ boolean
Checks if an object has been tagged for implementing the Thenable interface
as defined by webdriver.promise.Thenable.addImplementation
.
boolean
webdriver.promise.Thenable.addImplementation
.Parameters |
---|
|
Returns |
|