Constructor

Promise

new Promise(resolver)

A Promise represents an eventual (asynchronous) value. A Promise should (eventually) either resolve or reject. When it does, it will call all the callback functions that have been assigned via the .then() or .catch() methods.

firebase.Promise is the same as the native Promise implementation when available in the current environment, otherwise it is a compatible implementation of the Promise/A+ spec.

Parameter

resolver

function(function(T) returns void, function(non-null Error) returns void)

Implements
firebase.Thenable

Methods

all

static

all(values) returns firebase.Promise containing non-null Array of any type

Convert an array of Promises, to a single array of values. Promise.all() resolves only after all the Promises in the array have resolved.

Promise.all() rejects when any of the promises in the Array have rejected.

Parameter

values

Array of non-null firebase.Promise containing any type

Value must not be null.

Returns

non-null firebase.Promise containing non-null Array of any type 

reject

static

reject(error) returns firebase.Promise containing any type

Return (an immediately) rejected Promise.

Parameter

error

Error

The reason for the Promise being rejected.

Value must not be null.

Returns

non-null firebase.Promise containing any type 

resolve

static

resolve(value) returns firebase.Promise containing T

Return a resolved Promise.

Parameter

value

Optional

T

The value to be returned by the Promise.

Returns

non-null firebase.Promise containing T 

catch

catch(onReject)

Assign a callback when the Promise rejects.

Parameter

onReject

Optional

function(non-null Error) returns any type

Called when the Promise is rejected (with an error).

Implements
firebase.Thenable#catch

then

then(onResolve, onReject) returns firebase.Promise containing any type

Assign callback functions called when the Promise either resolves, or is rejected.

Parameter

onResolve

Optional

function(T) returns any type

Called when the Promise resolves.

onReject

Optional

function(non-null Error) returns any type

Called when the Promise is rejected (with an error).

Returns

non-null firebase.Promise containing any type 

Implements
firebase.Thenable#then