new Deferred()

Description

In the SuiteCommerce Extensibility API, the Deferred object is based on the JQuery Deferred object. It is safe to require JQuery by its AMD name "JQuery" and instantiate a Deferred object.

define('MyExtension', ['jQuery'], function(jQuery) {
			  var promise = jQuery.Deferred();
			})

Methods


promise() → {Deferred}

Description

Returns a Promise object.

Returns

notify( args ) → {Deferred}

Description

Calls the progressCallbacks on a Deferred object with the given arguments.

Parameters
Name Type Description
args Object

Optional arguments that are passed to the progressCallbacks.

Returns

fail( failCallbacks ) → {Deferred}

Description

Adds handlers to be called when the Deferred object is rejected.
This method accepts one or more arguments, all of which can be either a single function or an array of functions. When the Deferred is rejected, the failCallbacks are called.

Parameters
Name Type Description
failCallbacks function | Array.<function()>
Returns

state() → {string}

Description

Determines the current state of a Deferred object.

Returns

'pending'|'resolved'|'rejected'


done( doneCallbacks ) → {Deferred}

Description

Adds handlers to be called when the Deferred object is resolved.
This method accepts one or more arguments, all of which can be either a single function or an array of functions. When the Deferred is resolved, the doneCallbacks are called. Callbacks are executed in the order they were added.

Parameters
Name Type Description
doneCallbacks function | Array.<function()>
Returns

progress( progressCallbacks ) → {Deferred}

Description

Adds handlers to be called when the Deferred object generates progress notifications.
This method accepts one or more arguments, all of which can be either a single function or an array of functions. When Deferred.notify() is called, the function or functions are called.

Parameters
Name Type Description
progressCallbacks function | Array.<function()>
Returns

always( alwaysCallbacks ) → {Deferred}

Description

Adds handlers to be called when the Deferred object is either resolved or rejected.
The deferred.always() method receives the arguments that were used to .resolve() or .reject() the Deferred object, which are often very different.

Parameters
Name Type Description
alwaysCallbacks function | Array.<function()>

A function, or array of functions, that is called when the Deferred is resolved or rejected.

Returns

then( doneFilter [, failFilter [, progressFilter ] ] ) → {Deferred}

Description

Adds handlers to be called when the Deferred object is resolved, rejected, or in progress.

Parameters
Name Type Attributes Description
doneFilter function

A function that is called when the Deferred is resolved.

failFilter function <optional>

An optional function that is called when the Deferred is rejected.

progressFilter function <optional>

An optional function that is called when progress notifications are sent.

Returns

resolve( args ) → {Deferred}

Description

Resolve a Deferred object and call any doneCallbacks with the given args.

Parameters
Name Type Description
args object
Returns

reject( args ) → {Deferred}

Description

Rejects a Deferred object and calls any failCallbacks with the given arguments.

Parameters
Name Type Description
args Object

Optional arguments that are passed to the failCallbacks.

Returns