Creates a Promise that is fulfilled when all the values are fulfilled.
Syntax
promise.join(values).done( /* Your success and error handlers */ );
Parameters
- values
-
Type: Object
An object whose members contain values, some of which may be promises.
Return value
Type: Promise
A Promise whose value is an object with the same field names as those of the object in the values parameter, where each field value is the fulfilled value of a promise.
Examples
The following code shows how to use this function. Note that you must use the then function rather than the done function when you join promises. The done function returns undefined rather than a promise, so that joining promises that use done is the same as joining three instances of undefined.
<div id ="result1"></div> <div id = "result2"></div> <div id="result3"></div> <div id="join"></div> <script type="text/javascript"> var promiseArray = []; var index = 0; promiseArray[0] = WinJS.Promise.timeout(2000). then(function () { document.getElementById("result1").textContent = "First promise is fullfilled after 2 seconds"; }); promiseArray[1] = WinJS.Promise.timeout(3000). then(function () { document.getElementById("result2").textContent = "Second promise is fullfilled after 3 seconds"; }); promiseArray[2] = WinJS.Promise.timeout(4000). then(function () { document.getElementById("result3").textContent = "Third promise is fullfilled after 4 seconds"; }); WinJS.Promise.join(promiseArray). done(function () { var endDiv = document.getElementById("join"); endDiv.style.backgroundColor = "green"; endDiv.textContent = "Calling join() makes sure that this function will not be called until all the promises have been completed"; }); </script>
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
WinJS |
|
Library |
|
See also
Build date: 12/5/2012