Promise Class
+ + + + +A promise represents a value that may not yet be available. Promises allow +you to chain asynchronous operations, write synchronous looking code and +handle errors throughout the process.
+ +This constructor takes a function as a parameter where you can insert the logic +that fulfills or rejects this promise. The fulfillment value and the rejection +reason can be any JavaScript value. It's encouraged that rejection reasons be +error objects
+ +
+var fulfilled = new Y.Promise(function (fulfill) {
+ fulfill('I am a fulfilled promise');
+});
+
+var rejected = new Y.Promise(function (fulfill, reject) {
+ reject(new Error('I am a rejected promise'));
+});
+
+Constructor
+Promise
+
+
+ -
+
+
-
+
+
fn+ +
+
+
Parameters:
+ +-
+
+
-
+
+
fn+ Function + + + + +++ + +A function where to insert the logic that resolves this + promise. Receives
+fulfillandrejectfunctions as parameters. + This function is called synchronously.
+
+
-
+
- Index + + +
- Methods + + +
- Properties + + + +
Item Index
+ + + + + + +Properties
+ +-
+
+
- + _resolver + + + + + +
Methods
+ + +getStatus
+
+
+ ()
+
+
+
+
+ String
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Returns the current status of the operation. Possible results are +"pending", "fulfilled", and "rejected".
+Returns:
+ +isPromise
+
+
+ -
+
+
-
+
+
obj+ +
+
+
Checks if an object or value is a promise. This is cross-implementation +compatible, so promises returned from other libraries or native components +that are compatible with the Promises A+ spec should be recognized by this +method.
+Parameters:
+ +-
+
+
-
+
+
obj+ Any + + + + +++ + +The object to test
+
+
+
Returns:
+ +then
+
+
+ -
+
+
-
+
+
[callback]+ +
+
+ -
+
+
[errback]+ +
+
+
Schedule execution of a callback to either or both of "fulfill" and
+"reject" resolutions for this promise. The callbacks are wrapped in a new
+promise and that 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.
Asynchronicity of the callbacks is guaranteed.
+Parameters:
+ + +Returns:
+ +Properties
+ + +_resolver
+ Object
+
+
+
+
+ private
+
+
+
+
+
+
+
+
+ A reference to the resolver object that handles this promise
+