`
highfly-s
  • 浏览: 96910 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

async when then

阅读更多

 

function test1(){

var def = new  $.Deferred;

setTimeout(function() {

console.log(1)

def.resolve();

}, 1000);

return def;

}

 

function test2(){

 

var def = new  $.Deferred;

setTimeout(function() {

console.log(2)

def.resolve();

}, 1000);

return def;

}

 

function test3(){

var def = new  $.Deferred;

setTimeout(function() {

console.log(3)

def.resolve();

}, 1000);

return def;

}

 

var init = new  $.Deferred;

var pipeline =  init;

var lastDef =  init;

 

 

init.then(function(){ 

var d = [];   

for (var i = 0; i < 3; i++) {

d.push(window['test'+(i+1)]())

};

return d;

})

 

init.resolve();

 

// $.when(test1(), test2(), test3()).progress(function(one, two ,three) {

// console.log(three)

// })

分享到:
评论

相关推荐

    react-native-async-storage

    ####安装npm install react-native-async-storage ####方法 ####简单的例子 ReactNativeAsyncStorage.using('model_name') .then((model) =&gt; { model.get(id); model.find(); model.add({field1: 'value...

    async:R中的异步HTTP和计算

    合并延迟值的操作: $then() , $when_all() , when_any() , when_some() , $finally()和$catch()操作来处理错误。 一个强大的所有权模型:每个递延值都有一个接收其异步计算结果(或错误)的孩子。 同步...

    when:在事件触发之前或之后订阅事件

    什么时候 版本 作者 版权和许可 名称 什么时候-在事件触发之前或之后订阅事件 特征 没有依赖 小于500 B缩小+压缩 全类型(TypeScript) CDN构建(UMD) -jsDelivr , ... then ( ( [ event ] ) =&gt; addWidget ( user

    Mastering TypeScript-Second Edition[February 2017]

    Chapter 5, Writing and Using Declaration Files, walks the reader through building a declaration file for an existing body of JavaScript code, and then lists some of the most common syntax used when ...

    DebuggingWithGDB 6.8-2008

    Table of Contents Summary of gdb . . . . . . . . ....Free Software ....Free Software Needs Free Documentation ....Contributors to gdb....1 A Sample gdb Session ....2 Getting In and Out of gdb ....2.1 Invoking gdb ....

    Spring Boot 2 Recipes: A Problem-Solution Approach

    When you start a new project, you’ll be able to copy the code and configuration files from this book, and then modify them for your needs. This can save you a great deal of work over creating a ...

    SignalR Blueprints(PACKT,2015)

    In this book, you'll learn the technical aspects of SignalR and understand why and when you should use SignalR in different use cases. The focus on quality combined with clear, real-world examples ...

    promisify-node-callback:一个小工具,用于将基于回调的异步函数转换为基于承诺的异步函数

    承诺节点回调 一个小工具,用于将基于回调的异步函数转换为基于承诺的异步函数。... // does something async, returns `data` when good, `err` when bad if(err) { return callback(err); } return c

    async-script:一个微小的 AngularJS 模块,用于加载 JS 文件并在加载时解析承诺

    异步脚本加载一个 JS 文件并在完成后运行一些东西(通过 Promises) // inject "loadScriptAsync" function anywherefunction (loadScriptAsync) {loadScriptAsync('http://the.script.com/script.js').then...

    Reactive Android Programming

    However, he has soon learned that Android lacks a decent support for asynchronous programming (Async Task was/is a joke) while more reckless languages such as JavaScript had Promises for a long time....

    Csharp.6.for.Programmers.6th.Edition

    Start with an introduction to C# using an early classes and objects approach, then rapidly move on to more advanced topics, including LINQ, asynchronous programming with async and await and more....

    通用中间件Middl.zip

    // or when using Babel and async/await: app.use(async (input, output) =&gt; {  var start = new Date();  await next();  var ms = new Date() - start;  console.log('Done in %...

    Node.js Design Patterns_Second Edition

    Design and implement a series of server-side JavaScript patterns so you understand why and when to apply them in different use case scenarios Become comfortable with writing asynchronous code by ...

    Senfore_DragDrop_v4.1

    Delphi's THandle type when a HWND is passed to a function. E.g.: if (DragDetectPlus(THandle(MyControl-&gt;Handle), Point(X, Y))) { ... } * Virtual File Stream formats can only be pasted from the ...

    Learning Angular, 2nd Edition-Packt Publishing(2017).epub

    We address how to think and how to use the most common structural directives in order to control how the data should be displayed and act when being manipulated by UI elements. Chapter 7, ...

    insistence:坚持运行回调,并且仅在结果为真时才解析promise

    @bitty/insistence 始终执行回调,并且仅在结果为true时才解决promise。 安装 使用NPM或Yarn安装。 # Using NPM npm install @bitty/insistence --save # Using Yarn ... // It's only resolved when windo

    ICS delphixe10源码版

    all developers having contributed (When no name is given, the change is by F. Piette). I can't list all contributors here but I want to specially thanks two specially active contributors: - Arno ...

    r40_tinav2.1_最终验证通过_使用CB-S来验证OV5640有横条纹fpscamera+SPI2.0成功_20171114_1443没有外层目录.7z

    r40_tinav2.1_最终验证通过_使用CB-S来验证OV5640有横条纹fpscamera+SPI2.0成功_20171114_1443没有外层目录.7z ... //get target frame exif info successfully then save the target image //if get the exif info...

Global site tag (gtag.js) - Google Analytics