jQuery Deferred

码农软件 · 软件分类 · 其他jQuery插件 · 2020-01-08 10:43:07

软件介绍

Simple and clean asynchronous/nonblocking processing system JSDeferred (is like MochiKit and with some extension) with jQuery supports.

jQuery supports: overwrite ajax functions get, post and getJSON to return Deferred object (no arguments change).

Collect some asynchronous resources by ajax.

 

parallel([
    $.get("a.html").next(function (data) {
        return data.match(/([^<]+)<\/title>/);
    }),
    $.get("b.txt" ).next(function (data) {
        return data.match(/##\s*([^<]+)\s*##/);
    }),
    $.getJSON("c.json").next(function (data) {
        return data.title;
    })
]).next(function (values) {
    print("Titles "+values.join(", "));
});

 

Divided loop for non stress browsing. When long time processing is required, it is bad that simply using only for loop because it stops browser appearance. Deferred resolves it with bare minimum of effort.

 

loop({begin: 1, end:100, step:10}, function (n, o) {
    print(["Processing divided loop:n=", n].join(""));
    for (var i = 0; i < o.step; i++) {
        var j = n + i;
        print(j);
    }
});

 

Like tail call code. If you are habituated to functional programming, this syntax may be familiar to you.

 

next(function () {
    function pow (x, n) {
        function _pow (n, r) {
            if (n == 0) return r;
            return call(_pow, n - 1, x * r);
        }
        return call(_pow, n, 1);
    }
    return call(pow, 2, 10);
}).
next(function (r) {
    log([r, "end"]);
});

 

See more samples!

本文地址:https://codercto.com/soft/d/22919.html

Unity 3D游戏开发(第2版)

Unity 3D游戏开发(第2版)

宣雨松 / 人民邮电出版社 / 2018-9 / 89.00元

Unity 是一款市场占有率非常高的商业游戏引擎,横跨25 个主流游戏平台。本书基于Unity 2018,结合2D 游戏开发和3D 游戏开发的案例,详细介绍了它的方方面面,内容涉及编辑器、游戏脚本、UGUI 游戏界面、动画系统、持久化数据、静态对象、多媒体、资源加载与优化、自动化与打包等。 本书适合初学者或者有一定基础的开发者阅读。一起来看看 《Unity 3D游戏开发(第2版)》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试