Class Index | File Index

## Classes

- _global_
- comb
- comb.array
- comb.characters
- comb.collections
- comb.collections.AnderssonTree
- comb.collections.AVLTree
- comb.collections.BinaryTree
- comb.collections.Collection
- comb.collections.HashTable
- comb.collections.Heap
- comb.collections.Iterable
- comb.collections.MaxHeap
- comb.collections.MinHeap
- comb.collections.Pool
- comb.collections.PriorityQueue
- comb.collections.Queue
- comb.collections.RedBlackTree
- comb.collections.Stack
- comb.collections.Tree
- comb.date
- comb.logging
- comb.logging.appenders
- comb.logging.appenders.Appender
- comb.logging.appenders.ConsoleAppender
- comb.logging.appenders.FileAppender
- comb.logging.appenders.JSONAppender
- comb.logging.appenders.RollingFileAppender
- comb.logging.BasicConfigurator
- comb.logging.Level
- comb.logging.Logger
- comb.logging.PropertyConfigurator
- comb.number
- comb.plugins
- comb.plugins.Broadcaster
- comb.plugins.Middleware
- comb.Promise
- comb.PromiseList
- comb.regexp
- comb.string

# Class comb.Promise

Defined in: promise.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| comb.Promise() Promise object used for handling a thread

Method Summary
Method Attributes | Method Name and Description
--- | ---
| addCallback(cb) Add a callback to the callback chain of the promise
| addErrback(cb) 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)