diff -r 322d0feea350 -r 89ef5ed3c48b src/cm/media/js/lib/yui/yui_3.10.3/api/classes/Promise.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cm/media/js/lib/yui/yui_3.10.3/api/classes/Promise.html Tue Jul 16 14:29:46 2013 +0200 @@ -0,0 +1,2141 @@ + + + + + Promise - YUI 3 + + + + + + + + +
+
+
+ +

+ +
+
+ API Docs for: 3.10.3 +
+
+
+ +
+ +
+
+
+ Show: + + + + + + + +
+ + +
+
+
+

Promise Class

+
+ + + + + +
+ Defined in: promise/js/promise.js:27 +
+ + + + + Module: promise + + + + +
+ + + +
+

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 + +
  • + +
) +
+ + + + + + + + + + + + + + + + +
+ + + +

+ + Defined in + + + + + promise/js/promise.js:27 + +

+ + + + + +
+ +
+ +
+ + +
+

Parameters:

+ +
    + +
  • + + fn + Function + + + + +
    +

    A function where to insert the logic that resolves this + promise. Receives fulfill and reject functions as parameters. + This function is called synchronously.

    +
    + + +
  • + +
+
+ + + + + +
+ +
+ + +
+ + +
+
+

Item Index

+ + +
+

Methods

+ + +
+ + + +
+

Properties

+ + +
+ + + + + +
+ + +
+

Methods

+ + +
+

getStatus

+ + + () + + + + + String + + + + + + + + + + + + + + + +
+ + + +

+ + Defined in + + + + + promise/js/promise.js:98 + +

+ + + + + +
+ +
+

Returns the current status of the operation. Possible results are +"pending", "fulfilled", and "rejected".

+
+ + + + +
+

Returns:

+ +
+ + + String: + + +
+
+ + + +
+ + +
+

isPromise

+ + +
+ (
    + +
  • + + obj + +
  • + +
) +
+ + + + + Boolean + + + + + + + + + + + static + + + + + + +
+ + + +

+ + Defined in + + + + + promise/js/promise.js:110 + +

+ + + + + +
+ +
+

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:

+ +
+ + + Boolean: + + Whether the object is a promise or not + +
+
+ + + +
+ + +
+

then

+ + +
+ (
    + +
  • + + [callback] + +
  • + +
  • + + [errback] + +
  • + +
) +
+ + + + + Promise + + + + + + + + + + + + + + + +
+ + + +

+ + Defined in + + + + + promise/js/promise.js:77 + +

+ + + + + +
+ +
+

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:

+ +
    + +
  • + + [callback] + Function + optional + + + + +
    +

    function to execute if the promise + resolves successfully

    +
    + + +
  • + +
  • + + [errback] + Function + optional + + + + +
    +

    function to execute if the promise + resolves unsuccessfully

    +
    + + +
  • + +
+
+ + + +
+

Returns:

+ +
+ + + Promise: + + A promise wrapping the resolution of either "resolve" or + "reject" callback + +
+
+ + + +
+ + +
+ + + +
+

Properties

+ + +
+

_resolver

+ Object + + + + + private + + + + + + +
+ + + +

+ + Defined in + + + + + promise/js/promise.js:60 + +

+ + + + +
+ +
+

A reference to the resolver object that handles this promise

+
+ + + + + + +
+ + +
+ + + + + +
+
+ +
+
+
+
+
+
+ + + + + + + + + +