W3cubDocs

/Dojo

dojo/when

Summary

Transparently applies callbacks to values and/or promises.

Accepts promises but also transparently handles non-promises. If no callbacks are provided returns a promise, regardless of the initial value. Foreign promises are converted.

If callbacks are provided and the initial value is not a promise, the callback is executed immediately with no error handling. Returns a promise if the initial value is a promise, or the result of the callback otherwise.

Usage

when(valueOrPromise,callback,errback,progback);
Parameter Type Description
valueOrPromise undefined

Either a regular value or an object with a then() method that follows the Promises/A specification.

callback Function
Optional

Callback to be invoked when the promise is resolved, or a non-promise is received.

errback Function
Optional

Callback to be invoked when the promise is rejected.

progback Function
Optional

Callback to be invoked when the promise emits a progress update.

Returns: dojo/promise/Promise | summary: | name:

Promise, or if a callback is provided, the result of the callback.

See the dojo/when reference documentation for more information.

Methods

© 2005–2017 JS Foundation
Licensed under the AFL 2.1 and BSD 3-Clause licenses.
http://dojotoolkit.org/api/1.10/dojo/when.html