Promise object

WinJS.Promise object

[This documentation is preliminary and is subject to change.]

Applies to: Metro style apps only

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.

Syntax


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

Members

The Promise object has these types of members:

Events

The Promise object has these events.

EventDescription
onerror

Occurs when there is an error in processing.

 

Methods

The Promise object has these methods.

MethodDescription
addEventListener

Adds an event listener for the promise.

any

Returns a promise that is fulfilled when one of the input promises has been fulfilled.

as

Returns a promise. If the object is already a Promise it is returned; otherwise the object is wrapped in a 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.

is

Determines whether a value fulfills the promise contract.

join

Creates a Promise that is fulfilled when all the values are fulfilled.

Promise constructor

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.

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.

theneach

Performs an operation on all the input promises and returns a promise that has the shape of the input and contains the result of the operation that has been performed on each input.

timeout

Creates a promise that is fulfilled after a timeout.

wrap

Wraps a non-promise value in a promise. You can use this function if you need to pass a value to a function that requires a promise.

wrapError

Wraps a non-promise error value in a promise. You can use this function if you need to pass an error to a function that requires a promise.

 

Requirements

Minimum supported client

Windows 8 Consumer Preview

Minimum supported server

Windows Server 8 Beta

Namespace

WinJS

Library

Base.js

 

 

Build date: 2/10/2012

Ajouts de la communauté

AJOUTER
Afficher:
© 2017 Microsoft