Class: Promise

barejs/polyfill.Promise(_resolver)

new Promise(_resolver)

Create a new Promise

Parameters:
Name Type Description
_resolver function

The resolver function that will be called with two callbacks: _resolve (call on succes) and _reject (call on failure).

Source:

Methods

(static) all(_iterable) → {module:barejs/polyfill.Promise}

The Promise.all( _iterable ) method returns a promise that resolves when all of the promises in the iterable argument have resolved. If any of the passed in promises rejects, the all Promise immediately rejects with the value of the promise that rejected, discarding all the other promises whether or not they have resolved.

Parameters:
Name Type Description
_iterable Object

Array that can be iterated.

Source:
Returns:

A promise that will resolve with an array of values corresponding to all Promises in _iterable, after every Promise is resolved.

Type
module:barejs/polyfill.Promise

(static) race() → {module:barejs/polyfill.Promise}

The Promise.race( _iterable ) method returns a promise that resolves or rejects as soon as one of the promises in the iterable resolves or rejects, with the value or reason from that promise.

Source:
Returns:

A promise that will resolve with the value of the first Promise to resolve.

Type
module:barejs/polyfill.Promise

(static) reject(_reason) → {module:barejs/polyfill.Promise}

The Promise.reject( _reason ) method returns a Promise object that is rejected with the given reason.

Parameters:
Name Type Description
_reason *

The rejection reason (passed as rejection argument).

Source:
Returns:

A Promise that is rejected with _reason.

Type
module:barejs/polyfill.Promise

(static) resolve(_value) → {module:barejs/polyfill.Promise}

The Promise.resolve( _value ) method returns a Promise object that is resolved with the given value. If the value is a thenable (i.e. has a then method), the returned promise will "follow" that thenable, adopting its eventual state; otherwise the returned promise will be fulfilled with the value.

Parameters:
Name Type Description
_value *

The value to resolve with.

Source:
Returns:

A Promise that is resolved with _value.

Type
module:barejs/polyfill.Promise

catch() → {module:barejs/polyfill.Promise}

Register a rejection callback (shortcut for then( null, _onRejected ) ).

Source:
Returns:

A promise that will resolve or reject with the value returned by (or thrown from) _onRejected.

Type
module:barejs/polyfill.Promise

then() → {module:barejs/polyfill.Promise}

Register either a resolve or reject callback, or both.

Source:
Returns:

A promise that will resolve or reject with the value returned by (or thrown from) _onFulfilled or _onRejected.

Type
module:barejs/polyfill.Promise