Windows-Apps
Inhaltsverzeichnis reduzieren
Inhaltsverzeichnis erweitern
EN
Dieser Inhalt ist in Ihrer Sprache leider nicht verfügbar. Im Folgenden finden Sie die englische Version.

WinJS.Promise object

Applies to Windows and Windows Phone

Provides a mechanism to schedule work to be done on a value that has not yet been computed. It is an abstraction for managing interactions with asynchronous APIs.

For more information about asynchronous programming, see Asynchronous programming. For more information about promises in JavaScript, see Asynchronous programming in JavaScript.

Syntax


var aPromise = new WinJS.Promise(init, onCancel);

Members

The Promise object has these types of members:

Constructors

The Promise object has these constructors.

ConstructorDescription
Promise

A promise provides a mechanism to schedule work to be done on a value that has not yet been computed. It is a convenient abstraction for managing interactions with asynchronous APIs.

For more information about asynchronous programming, see Asynchronous programming. For more information about promises in JavaScript, see Asynchronous programming in JavaScript.

 

Events

The Promise object has these events.

EventDescription
onerror

Occurs when there is an error in processing a promise.

 

Methods

The Promise object has these methods.

MethodDescription
addEventListener

Adds an event listener for the promise.

cancel

Attempts to cancel the fulfillment of a promised value. If the promise hasn't already been fulfilled and cancellation is supported, the promise enters the error state with a value of Error("Canceled").

dispatchEvent

Raises an event of the specified type and properties.

done

Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. After the handlers have finished executing, this function throws any error that would have been returned from then as a promise in the error state.

For more information about the differences between then and done, see the following topics:

removeEventListener

Removes an event listener from the control.

then

Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way.

For more information about the differences between then and done, see the following topics:

 

Requirements

Minimum WinJS version

WinJS 2.0

Namespace

WinJS

 

 

Anzeigen:
© 2016 Microsoft