com.ibm.mashups.enabler
Interface Deferred


public Deferred

Base interface for all classes which handle actions asynchronously. An action may involve one or more operations, for example creating or updating a model resource, which in turn may involve one or more HTTP requests. The Deferred interface allows to trigger a callback after the entire action, i.e. all involved HTTP requests, is finished. Thus, the Deferred interface may be used to get the overall result of an action.


Method Summary
 Deferred setFinishedCallback(Object callback, Object parameter, Boolean verbose)
           Sets the handler of the deferred action.
 Object start(Boolean sync)
           Executes the deferred action and invokes the callback functions set with the deferred object after the action finished.
 

Method Detail

setFinishedCallback

Deferred setFinishedCallback(Object callback,
                             Object parameter,
                             Boolean verbose)
Sets the handler of the deferred action. It is called when the entire action has finished.
Notes:

Parameters:
callback - the callback function in either one of the following flavors:
  • verbose mode: function(Object verboseFinishResult), where:
    verboseFinishResult = {
        resource: resource object or id string of the related resource,
        parameter: the parameter passed into setFinishedCallback,
        request: {
            statusCode: HTTP status code,
            responseText: server response text
        }
    }
  • non-verbose mode: function(Object resource, int statusCode, Object parameter), where:
    • resource: resource object or id string of the related resource
    • statusCode: HTTP status code
    • parameter: the parameter passed into setFinishedCallback
parameter - optional parameter to be passed on to the callback function; may be null
verbose - flag to indicate if the callback function is invoked in verbose or non-verbose mode; optional, defaults to false
Returns:
the deferred object

start

Object start(Boolean sync)
Executes the deferred action and invokes the callback functions set with the deferred object after the action finished.

Parameters:
sync - indicates if the deferred action is executed synchronously or asynchronously. Optional, defaults to true.
Returns:
resource if called asynchronously, the return value is undefined, otherwise a resource object or id string of the related resource is returned.
In order to obtain information on the resource as well as on the status code of the operation, you must use the callback functions of the deferred object.


Copyright IBM Corp. 2010 All Rights Reserved.