]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/promise/Promise.js.uncompressed.js
1 define("dojo/promise/Promise", [
7 // dojo/promise/Promise
9 function throwAbstract(){
10 throw new TypeError("abstract");
13 return lang
.extend(function Promise(){
15 // The public interface to a deferred.
17 // The public interface to a deferred. All promises in Dojo are
18 // instances of this class.
20 then: function(callback
, errback
, progback
){
22 // Add new callbacks to the promise.
24 // Add new callbacks to the deferred. Callbacks can be added
25 // before or after the deferred is fulfilled.
26 // callback: Function?
27 // Callback to be invoked when the promise is resolved.
28 // Receives the resolution value.
30 // Callback to be invoked when the promise is rejected.
31 // Receives the rejection error.
32 // progback: Function?
33 // Callback to be invoked when the promise emits a progress
34 // update. Receives the progress update.
35 // returns: dojo/promise/Promise
36 // Returns a new promise for the result of the callback(s).
37 // This can be used for chaining many asynchronous operations.
42 cancel: function(reason
, strict
){
44 // Inform the deferred it may cancel its asynchronous operation.
46 // Inform the deferred it may cancel its asynchronous operation.
47 // The deferred's (optional) canceler is invoked and the
48 // deferred will be left in a rejected state. Can affect other
49 // promises that originate with the same deferred.
51 // A message that may be sent to the deferred's canceler,
52 // explaining why it's being canceled.
54 // If strict, will throw an error if the deferred has already
55 // been fulfilled and consequently cannot be canceled.
57 // Returns the rejection reason if the deferred was canceled
63 isResolved: function(){
65 // Checks whether the promise has been resolved.
71 isRejected: function(){
73 // Checks whether the promise has been rejected.
79 isFulfilled: function(){
81 // Checks whether the promise has been resolved or rejected.
87 isCanceled: function(){
89 // Checks whether the promise has been canceled.
95 always: function(callbackOrErrback
){
97 // Add a callback to be invoked when the promise is resolved
99 // callbackOrErrback: Function?
100 // A function that is used both as a callback and errback.
101 // returns: dojo/promise/Promise
102 // Returns a new promise for the result of the callback/errback.
104 return this.then(callbackOrErrback
, callbackOrErrback
);
107 otherwise: function(errback
){
109 // Add new errbacks to the promise.
110 // errback: Function?
111 // Callback to be invoked when the promise is rejected.
112 // returns: dojo/promise/Promise
113 // Returns a new promise for the result of the errback.
115 return this.then(null, errback
);
122 traceRejected: function(){
126 toString: function(){
128 // Returns `[object Promise]`.
130 return "[object Promise]";