Namespace i$.promise
Contains static functions related to promise capabilities
Constructor Attributes | Constructor Name and Description |
---|---|
Entry point for accessing functions that provide enhanced capabilities for using Promises.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
i$.promise.isPromise(o)
Determines if an object is a Promise or not.
|
<static> |
i$.promise.join(arr)
Joins multiple Promises together into a new Promise that resolves to an array of all the
resulting values of the Promises that have been joined.
|
<static> |
i$.promise.rejected(err)
Returns a new Promise that is rejected with the value err
|
<static> |
i$.promise.resolved(o)
Returns a new Promise that is resolved with the given value
|
<static> |
i$.promise.when(o)
Returns a Promise that is resolved with the given value o as its value if o is not already
a Promise.
|
<static> |
i$.promise.whenAll(o)
Returns a new Promise that is resolved when all of the arguments have a resolved
value either by being a non-Promise value to begin with or by being Promises that
are eventually resolved.
|
Namespace Detail
i$.promise
Entry point for accessing functions that provide enhanced capabilities for using Promises.
Method Detail
<static>
{Boolean}
i$.promise.isPromise(o)
Determines if an object is a Promise or not.
- Parameters:
- {Object} o
- An object to test. Must not be null, or will always return false.
- Returns:
- {Boolean} true if the object is a Promise, false otherwise
<static>
{i$.promise.Promise}
i$.promise.join(arr)
Joins multiple Promises together into a new Promise that resolves to an array of all the
resulting values of the Promises that have been joined.
- Parameters:
- {Array[i$.promise.Promise]} arr
- An array of Promises to join. Must not be null, or will fail with a null pointer exception.
- Returns:
- {i$.promise.Promise} A new promise that resolves whenever all the Promises that were used to create it are resolved. If any of them reject, this returned Promise rejects. The resolved or rejected value of this Promise is an array of the resolved values of the sub-Promises it consists of whose indices match the indices of the original argument array. Never null.
<static>
{i$.promise.Promise}
i$.promise.rejected(err)
Returns a new Promise that is rejected with the value err
- Parameters:
- {Object} err
- The error object to reject the returned Promise with. May be null.
- Returns:
- {i$.promise.Promise} A rejected Promise. Never null.
<static>
{i$.promise.Promise}
i$.promise.resolved(o)
Returns a new Promise that is resolved with the given value
- Parameters:
- {Object} o
- The value to resolve the returned Promise with. May be null.
- Returns:
- {i$.promise.Promise} A resolved Promise. Never null.
<static>
{i$.promise.Promise}
i$.promise.when(o)
Returns a Promise that is resolved with the given value o as its value if o is not already
a Promise. If o is already a Promise, this simply returns it again. This
allows easy programming patterns that don't need to check if a return value from
another function is a Promise or not but can simply operate on it as if it were
a Promise.
Please note: For faster access this object has been made available directly on i$ as i$.when.
Example 1 i$.when(5).then(function(data){ // data is 5 alert(data); // alerts 5 });
Example 2 i$.when(i$.promise.resolved(5)).then(function(data){ // data is 5 alert(data); // alerts 5 });
- Parameters:
- {Object} o
- Value to transform into a promise if necessary. May be null.
- Returns:
- {i$.promise.Promise} A valid promise. Never null.
<static>
{i$.promise.Promise}
i$.promise.whenAll(o)
Returns a new Promise that is resolved when all of the arguments have a resolved
value either by being a non-Promise value to begin with or by being Promises that
are eventually resolved. Each argument is normalized using i$.promise.when.
Please note: For faster access this object has been made available directly on i$ as i$.whenAll.
- Parameters:
- {Object|...} o
- A comma separated list of objects to be passed into i$.promise.when. Must not be null, or will fail with a null pointer exception.
- Returns:
- {i$.promise.Promise} A new promise that resolves whenever all the Promises that were used to create it are resolved. If any of them reject, this returned Promise rejects. The resolved or rejected value of this Promise is an array of the resolved values of the sub-Promises it consists of whose indices match the indices of the original argument array. Never null.