Class Index | File Index

Classes


Class comb.Promise


Defined in: promise.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Promise object used for handling a thread
Method Summary
Method Attributes Method Name and Description
 
Add a callback to the callback chain of the promise
 
Add a callback to the errback chain of the promise
 
callback(anything)
When called all functions registered as callbacks are called with the passed in results.
 
chain(callback, errback)
Call to chaining of promises
 
errback(anything)
When called all functions registered as errbacks are called with the passed in error(s)
 
then(callback, errback)
Call to specify action to take after promise completes or errors
Class Detail
comb.Promise()
Promise object used for handling a thread
         var myFunc = function(){
             var promise = new Promise();
             //callback the promise after 10 Secs
             setTimeout(hitch(promise, "callback"), 10000);
             return promise;
         }
         var myFunc2 = function(){
             var promises =[];
             for(var i = 0; i < 10; i++){
                 promises.push(myFunc);
             }
             //create a new promise list with all 10 promises
             return new PromiseList(promises);
         }

         myFunc.then(do something...)
         myFunc.addCallback(do something...)
         myFunc.cain(myfunc).then(do something...)
         myFunc.cain(myfunc).addCallback(do something...)

         myFunc2.then(do something...)
         myFunc2.addCallback(do something...)
         myFunc2.cain(myfunc).then(do something...)
         myFunc2.cain(myfunc).addCallback(do something...)
Method Detail
addCallback(cb)
Add a callback to the callback chain of the promise
Parameters:
{Function} cb
the function to callback when the promise is resolved

addErrback(cb)
Add a callback to the errback chain of the promise
Parameters:
{Function} cb
the function to callback when the promise errors

callback(anything)
When called all functions registered as callbacks are called with the passed in results.
Parameters:
anything
variable number of results to pass back to listeners of the promise

chain(callback, errback)
Call to chaining of promises
Parameters:
callback
method to call that returns a promise to call after this one completes.
errback
method to call if this promise errors.

errback(anything)
When called all functions registered as errbacks are called with the passed in error(s)
Parameters:
anything
variable number of errors to pass back to listeners of the promise

then(callback, errback)
Call to specify action to take after promise completes or errors
Parameters:
{Function} callback Optional, Default: null
function to call after the promise completes successfully
{Function} errback Optional, Default: null
function to call if the promise errors

Documentation generated by JsDoc Toolkit 2.4.0 on Tue Oct 25 2011 13:20:07 GMT-0500 (CDT)