async异步流程控制神器
async
https://www.npmjs.com/package/async
Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use with Node.js and installable via
npm install async, it can also be used directly in the browser. A ESM version is included in the mainasyncpackage that should automatically be used with compatible bundlers such as Webpack and Rollup.A pure ESM version of Async is available as
async-es.For Documentation, visit https://caolan.github.io/async/
For Async v1.5.x documentation, go HERE
API
https://github.com/caolan/async/blob/v1.5.2/README.md#waterfall
Control Flow
动画
https://github.com/fanqingsong/async_animation
index.js
import './css/style.css';
import './sass/index.scss'; var async = require("async"); window.onload = () => {
let salutions = document.querySelectorAll("#salutions>div");
for(let one of salutions){
one.style.display = "none";
} async.waterfall([
function(callback) {
salutions[0].style.display = "flex"; setTimeout(callback, 1000);
},
function(callback) {
salutions[1].style.display = "flex"; setTimeout(callback, 1000);
},
function(callback) {
salutions[2].style.display = "flex"; setTimeout(callback, 1000);
},
function(callback) {
salutions[3].style.display = "flex"; setTimeout(callback, 1000);
},
function(callback) {
callback(null);
}
], function (err, result) {
// result now equals 'done'
});
};
html
<div class="c-Sticky">
<div class="c-Sticky-bd">
<h1 style="text-align: center;">Async Show</h1> <div id="salutions" style="font-size: xx-large; color:blue; display: flex; justify-content:center;">
<div style="display:flex;width:200px;height:200px; justify-content:center;align-items: center ; margin: 5px; background-color: steelblue">你</div>
<div style="display:flex;width:200px;height:200px; justify-content:center;align-items: center ; margin: 5px; background-color: antiquewhite">好</div>
<div style="display:flex;width:200px;height:200px; justify-content:center;align-items: center ; margin: 5px; background-color: azure">中</div>
<div style="display:flex;width:200px;height:200px; justify-content:center;align-items: center ; margin: 5px; background-color: beige">国</div>
</div> </div>
</div>
效果
显示从左到右每个一秒显示一个方块字。

async异步流程控制神器的更多相关文章
- nodejs进阶(7)—async异步流程控制
Async介绍 Async是一个流程控制工具包,提供了直接而强大的异步功能.基于Javascript为Node.js设计,同时也可以直接在浏览器中使用. Async提供了大约20个函数,包括常用的 m ...
- async 异步流程控制规则
github 学习async网址 : https://github.com/caolan/async/ 1.Async 函数介绍 async 主要实现了三个部分的流程控制功能 1.集合:Collect ...
- async异步流程控制
http://cnodejs.org/topic/54acfbb5ce87bace2444cbfb 先安装:G:\www\nodejs\one\models>npm install async ...
- Nodejs中使用异步流程控制Async
首先,我们都知道,Node基于事件驱动的异步I/O架构,所谓异步就是非阻塞,说白了就是一个事件执行了,我不必等待它执行完成后我才能执行下一个事件.所以在Node环境中的模块基本都是异步的,上一篇说到我 ...
- 【javascript】Promise/A+ 规范简单实现 异步流程控制思想
——基于es6:Promise/A+ 规范简单实现 异步流程控制思想 前言: nodejs强大的异步处理能力使得它在服务器端大放异彩,基于它的应用不断的增加,但是异步随之带来的嵌套.难以理解的代码让 ...
- node核心:异步流程控制
Node.js的异步是整个学习Node.js过程中重中之重. 1)异步流程控制学习重点 2)Api写法:Error-first Callback 和 EventEmitter 3)中流砥柱:Promi ...
- 使用yield进行异步流程控制
现状 目前我们对异步回调的解决方案有这么几种:回调,deferred/promise和事件触发.回调的方式自不必说,需要硬编码调用,而且有可能会出现复杂的嵌套关系,造成"回调黑洞" ...
- js 异步流程控制之 avQ(avril.queue)
废话前言 写了多年的js,遇到过最蛋疼的事情莫过于callback hell, 相信大家也感同身受. 业界许多大大也为此提出了很多不错的解决方案,我所了解的主要有: 朴灵 event proxy, 简 ...
- 异步流程控制库GoWithTheFlow
异步流程控制库GoWithTheFlow 一个尾触发方式来控制异步流程的库, 有seq(顺序执行) par(同步执行) 两种方法 博客 http://notes.jetienne.com/2011/0 ...
随机推荐
- iodine dig A
(base) bonelee@bonelee-VirtualBox:~/Desktop$ dig paeadgpy.abc.com @45.32.247.94 ; <<>> D ...
- php适配器模式(adapter pattern)
下午陪家人和小孩,晚上练起来. <?php /* The adapter pattern allows the interface of an existing class to be used ...
- Python中取整的方法floor,ceil,round
地板函数:math.floor(4.9)=4 天花板函数: math.ceil(4.1)=5 四舍五入: round(4.5)=4 round(4.6)=5
- python应用-猜数字游戏
import random def main(): answer = random.randint(1, 100) counter = 0 while True: counter += 1 numbe ...
- wordpress导航当前页面菜单高亮显示如何操作
我们在制作wordpress主题时有些客户要求导航在访问某个菜单时,这个菜单项会高亮显示,让用户知道自己正在访问的是哪个菜单下的内容,这个要如何实现呢?wordpress早就为你想好了,.curren ...
- Squeeze Excitation Module 对网络的改进分析
Squeeze-and-Excitation Networks SE-net 来自于Momenta 孙刚团队 SE的设计思路: 从卷积操作的实际作用来考虑,conv 把局部空间信息和通道信息组合起来, ...
- Codeforces Round #552 (Div. 3)-D-Walking Robot-(贪心)
http://codeforces.com/contest/1154/problem/D 解题: 1.无光的时候优先使用太阳能电池. 2.有光的时候 (1)太阳能电池没满电,让它充,使用普通电池 (2 ...
- Hibernate的级联保存、级联删除
级联操作: 属性:cascade 值:save-update(级联保存) delete(级联删除) all(级联保存+级联删除) 优点:虽然,不用级联操作也能解决问题.但是级联操作可以减少代码量,使得 ...
- http-server开启测试服务器
一.安装 npm install --global http-server 二.查看使用帮助 hs -h 三.基本使用 ①默认开启占用8080端口启动一个服务器,直接打开浏览器 hs -o ②指定都端 ...
- Morpheus
https://software.broadinstitute.org/morpheus/