jQuery promise, created from jQuery.Deferred object. See jQuery docs for more detailed information.
CobrowsePromised are used to resolve server responses to requests performed by AvayaCoBrowseClientServices.
See async for more information.
Note that since all CobrowsePromise methods return themselves, the methods can be easily chained.
Examples
var successCallback = function(){ AvayaCoBrowseClientServices.Base.CobrowseLogger.log("Something happened!"); }; var failCallback = function(){ AvayaCoBrowseClientServices.Base.CobrowseLogger.log("Error"); }; Cobrowse.doSomething(arguments).then(successCallback, failCallback); // do something else... // when the CobrowsePromise is resolved, AvayaCoBrowseClientServices.Base.CobrowseLogger will print "Something happened!"
Cobrowse.doSomething(arguments).done(doOneThing).done(doOther).done(doAnother).fail(onError);
Methods
-
always(alwaysCallback) → {AvayaCoBrowseClientServices.Base.CobrowsePromise}
-
Add handlers to be called when the Deferred object is either resolved or rejected.
Parameters:
Name Type Description alwaysCallback
function A function, or array of functions, that is called when the Deferred is resolved or rejected.
Returns:
-
done(doneCallback) → {AvayaCoBrowseClientServices.Base.CobrowsePromise}
-
Add handlers to be called when the Deferred object is resolved.
Example
Cobrowse.doSomething(arguments).done(function(data){ //invoked on success //e.g. refresh the UI });
Parameters:
Name Type Description doneCallback
function A function, or array of functions, that are called when the Deferred is resolved.
Returns:
-
fail(failCallback) → {AvayaCoBrowseClientServices.Base.CobrowsePromise}
-
Add handlers to be called when the Deferred object is rejected.
Example
Cobrowse.doSomething(arguments).fail(function(error){ //invoked on failure //e.g. show error in UI });
Parameters:
Name Type Description failCallback
function A function, or array of functions, that are called when the Deferred is rejected.
Returns:
-
progress(progressCallback) → {AvayaCoBrowseClientServices.Base.CobrowsePromise}
-
Add handlers to be called when the Deferred object generates progress notifications. Please note that not every CobrowsePromise
creates progress notifications.Example
Cobrowse.doSomething(arguments).progress(function(progressObject){ //invoked on progress //e.g. refresh progress bar });
Parameters:
Name Type Description progressCallback
function A function, or array of functions, to be called when the Deferred generates progress notifications.
Returns:
-
state() → {String}
-
Determine the current state of a Deferred object.
Returns:
{ String }
-
then(doneCallback, failCallback, progressCallback) → {AvayaCoBrowseClientServices.Base.CobrowsePromise}
-
Add handlers to be called for the Deferred object. Combines functionality of .done(), .fail() and .progress().
Example
Cobrowse.doSomething(arguments).then(function(data){ //invoked on success //e.g. refresh the UI }, function(error){ //invoked on failure //e.g. show error in UI }, function(progressObject){ //invoked on progress //e.g. refresh progress bar });
Parameters:
Name Type Argument Description doneCallback
function A function that is called when the Deferred is resolved.
failCallback
function <optional>
A function that is called when the Deferred is rejected.
progressCallback
function <optional>
A function that is called when the Deferred generates progress notifications.
Returns: