The PromiseUtils.jsm JavaScript code module offers some useful functions related to DOM Promise. To use it, you first need to import the code module into your JavaScript scope:

Components.utils.import("resource://gre/modules/PromiseUtils.jsm");

Method overview

Deferred defer();

Methods

defer()

Creates a new pending Promise and provides methods to resolve or reject this Promise.

This method was previously implemented as Promise.defer(), which is obsolete since Gecko 30. And PromiseUtils.defer uses DOM Promise instead of Promise.jsm's Promise.

Deferred defer();
Parameters

None.

Return value

A new object, containing the new promise in the promise property, and the methods to change its state in the resolve and reject properties. See the Deferred documentation for details.

See also