#

API Docs for: 3.10.3
Show: Inherited Protected Private Deprecated

# Promise.Resolver Class

Defined in: `promise/js/resolver.js:1`
Module: promise

Represents an asynchronous operation. Provides a standard API for subscribing to the moment that the operation completes either successfully (`fulfill()`) or unsuccessfully (`reject()`).

## Constructor

### `Promise.Resolver`

(

- `promise`

)

Defined in `promise/js/resolver.js:1`

#### Parameters:

- `promise` Promise

  The promise instance this resolver will be handling

- Index
- Methods
- Properties

## Item Index

### Methods

- _notify
- _wrap
- fulfill
- getStatus
- reject
- then

### Properties

- _callbacks
- _errbacks
- _status
- promise

## Methods

### `_notify`

(

- `subs`
- `result`

)
protected

Defined in `promise/js/resolver.js:232`

Executes an array of callbacks from a specified context, passing a set of arguments.

#### Parameters:

- `subs` Function[]

  The array of subscriber callbacks

- `result` Any

  Value to pass the callbacks

### `_wrap`

(

- `thenFulfill`
- `thenReject`
- `fn`

)
Function private

Defined in `promise/js/resolver.js:163`

Wraps the callback in Y.soon to guarantee its asynchronous execution. It also catches exceptions to turn them into rejections and links promises returned from the `then` callback.

#### Parameters:

- `thenFulfill` Function

  Fulfillment function of the resolver that handles this promise

- `thenReject` Function

  Rejection function of the resolver that handles this promise

- `fn` Function

  Callback to wrap

#### Returns:

Function:

### `fulfill`

(

- `value`

)

Defined in `promise/js/resolver.js:50`

Resolves the promise, signaling successful completion of the represented operation. All "onFulfilled" subscriptions are executed and passed the value provided to this method. After calling `fulfill()`, `reject()` and `notify()` are disabled.

#### Parameters:

- `value` Any

  Value to pass along to the "onFulfilled" subscribers

### `getStatus`

() String

Defined in `promise/js/resolver.js:221`

Returns the current status of the Resolver as a string "pending", "fulfilled", or "rejected".

#### Returns:

String:

### `reject`

(

- `value`

)

Defined in `promise/js/resolver.js:83`

Resolves the promise, signaling unsuccessful completion of the represented operation. All "onRejected" subscriptions are executed with the value provided to this method. After calling `reject()`, `resolve()` and `notify()` are disabled.

#### Parameters:

- `value` Any

  Value to pass along to the "reject" subscribers

### `then`

(

- `[callback]`
- `[errback]`

)
Promise

Defined in `promise/js/resolver.js:108`

Schedule execution of a callback to either or both of "resolve" and "reject" resolutions for the Resolver. The callbacks are wrapped in a new Resolver and that Resolver's corresponding promise is returned. This allows operation chaining ala `functionA().then(functionB).then(functionC)` where `functionA` returns a promise, and `functionB` and `functionC` may return promises.

#### Parameters:

- `[callback]` Function optional

  function to execute if the Resolver resolves successfully

- `[errback]` Function optional

  function to execute if the Resolver resolves unsuccessfully

#### Returns:

Promise: The promise of a new Resolver wrapping the resolution of either "resolve" or "reject" callback

## Properties

### `_callbacks`

Array private

Defined in `promise/js/resolver.js:11`

List of success callbacks

### `_errbacks`

Array private

Defined in `promise/js/resolver.js:20`

List of failure callbacks

### `_status`

String private

Defined in `promise/js/resolver.js:37`

The status of the operation. This property may take only one of the following values: 'pending', 'fulfilled' or 'rejected'.

Default: 'pending'

### `promise`

Promise

Defined in `promise/js/resolver.js:29`

The promise for this Resolver.