Namespace: webdriver.promise
View Source

# class Promise<T>

All implemented interfaces:
  `webdriver.promise.Thenable<T>`

Represents the eventual value of a completed operation. Each promise may be in one of three states: pending, fulfilled, or rejected. Each promise starts in the pending state and may make a single transition to either a fulfilled or rejected state, at which point the promise is considered resolved.

## new Promise(resolver, opt_flow)

Parameters

resolver`function(function(?(T|IThenable<T>|{then: Function})=): ?, function(*=): ?): ?`

  Function that is invoked immediately to begin computation of this promise's value. The function should accept a pair of callback functions, one for fulfilling the promise and another for rejecting it.

opt_flow`?webdriver.promise.ControlFlow=`

  The control flow this instance was created under. Defaults to the currently active flow.

## Instance Methods

### cancel(opt_reason)code »

Specified by: webdriver.promise.Thenable

Parameters

opt_reason`?(string|webdriver.promise.CancellationError)=`

### isPending()code »

Specified by: webdriver.promise.Thenable

Returns

`boolean`

### then(opt_callback, opt_errback)code »

Specified by: webdriver.promise.Thenable

Parameters

opt_callback`?function(T): (R|IThenable<R>)=`
opt_errback`?function(*): (R|IThenable<R>)=`

Returns

`webdriver.promise.Promise`

### thenCatch(errback)code »

Specified by: webdriver.promise.Thenable

Parameters

errback`function(*): (R|IThenable<R>)`

Returns

`webdriver.promise.Promise`

### thenFinally(callback)code »

Specified by: webdriver.promise.Thenable

Parameters

callback`function(): (R|IThenable<R>)`

Returns

`webdriver.promise.Promise`

### toString()code »

Returns

`string`

## Types

Promise.State_

  No description.