new Promise(o)
Promises/A+ spec compliant class, with a little extension
http://promises-aplus.github.io/promises-spec/
Parameters:
Name | Type | Description |
---|---|---|
o |
Promise.<T> | T | Object to wrap with promise |
- Source:
Methods
-
<static> all(promises) → {Promise.<Array.<*>>}
-
Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
Parameters:
Name Type Description promises
Array.<(Promise.<*>|*)> - Source:
Returns:
- Type
- Promise.<Array.<*>>
-
<static> defer() → {Deferred}
-
Returns a deferred object
- Source:
Returns:
- Type
- Deferred
-
<static> reject(reason) → {Promise}
-
Returns rejecting promise with given reason
Parameters:
Name Type Description reason
Error Rejecting reason - Source:
Returns:
- Type
- Promise
-
<static> when(p)
-
Parameters:
Name Type Argument Description p
...Promise.<*> <repeatable>
- Source:
-
done(onFulfilled) → {Promise.<S>}
-
Alias for completion
Parameters:
Name Type Argument Description onFulfilled
FulfilledCallback.<T, S> <optional>
- Source:
Returns:
- Type
- Promise.<S>
-
fail(onRejected) → {Promise.<S>}
-
A sugar method, equivalent to promise.then(undefined, onRejected).
Parameters:
Name Type Description onRejected
RejectedCallback.<S> - Source:
Returns:
- Type
- Promise.<S>
-
then(onFulfilled, onRejected) → {Promise.<(S1|S2)>}
-
The "then" method from the Promises/A+ specification
Parameters:
Name Type Argument Description onFulfilled
FulfilledCallback.<T, S1> <optional>
onRejected
RejectedCallback.<S2> <optional>
- Source:
Returns:
- Type
- Promise.<(S1|S2)>
-
thenCall(callback) → {Promise.<T>}
-
Call "then" using given node-style callback function
Parameters:
Name Type Argument Description callback
Callback.<T> <optional>
Callback function - Source:
Returns:
- Type
- Promise.<T>