WinJS.Promise(Function, Function) constructor

4 out of 6 rated this helpful - Rate this topic

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.

For more information about using promises, see the Promise sample at Windows Store app samples.

Syntax


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

Parameters

init

Type: Function

The function that is called during construction of the promise. The function is given three arguments (complete, error, progress). Inside this function you should add event listeners for the notifications supported by this value.

onCancel

Type: Function

The function to call if a consumer of this promise wants to cancel its undone work. Promises are not required to support cancellation.

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Namespace

WinJS

Library

Base.js

See also

Promise

 

 

Build date: 12/5/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.