Promise.any ---- 参数是一个promise的数组。any的作用就是 promise 数组中任意一个 promise 执行完毕,就会执行 done内的函数
(function () { "use strict"; WinJS.Binding.optimizeBindingReferences = true; var app = WinJS.Application; var activation = Windows.ApplicationModel.Activation; app.onactivated = function (args) { if (args.detail.kind === activation.ActivationKind.launch) { if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) { var promiseArr = []; var url = 'http://files.cnblogs.com/Mr-Joe/a.js'; var url2 = 'http://files.cnblogs.com/Mr-Joe/a2.js'; var success = function (text) { var a = JSON.parse(text.responseText); } var getData = function (url) { promiseArr.push(WinJS.xhr({ url: url })) } getData(url2); getData(url); WinJS.Promise.any(promiseArr).done(function (result) { var primiseIndex = result.index; //the index of fullfilled promise. }); } } args.setPromise(WinJS.UI.processAll()); }; app.start(); })();
Promise.join
Promise.any ---- 参数是一个promise的数组。any的作用就是 promise 数组所有的 promise 执行完毕,才会执行 done内的函数