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 ...
随机推荐
- 内核中dump_stack的实现原理(1) —— 栈回溯
环境 Aarch64 Qemu aarch64-linux-gnu-gcc linux-4.14 概述 栈回溯的目的是将函数的调用栈打印出来,对于分析函数调用和debug系统异常会很有帮助 ...
- linux设备驱动程序-i2c(2)-adapter和设备树的解析
linux设备驱动程序-i2c(2)-adapter和设备树的解析 (注: 基于beagle bone green开发板,linux4.14内核版本) 在本系列linux内核i2c框架的前两篇,分别讲 ...
- lvs+keepalived高可用负载均衡
一.实验环境和网络拓扑图 本实验需要5台虚拟机,一台客户机,2台lvs调度器,两台web服务器. 客户机:192.168.0.6/24 lvs1:192.168.0.201/24 lvs2:192.1 ...
- jenkins权限管理插件role-based(二)
一.安装role-based插件 jenkins默认自带“configure global security/全局安全配置”比较简陋,不建议使用 系统管理-->插件管理-->可选插件--& ...
- Pytorch数据读取详解
原文:http://studyai.com/article/11efc2bf#%E9%87%87%E6%A0%B7%E5%99%A8%20Sampler%20&%20BatchSampler ...
- 在kubernetes集群中部署ElasticSearch集群--ECK
Elastic Cloud on Kubernetes (ECK) ---ECK是这个说法哈. 基本于k8s operator的官方实现. URL: https://www.elastic.co/gu ...
- blockingqueue.h
#include <mutex> #include <condition_variable> #include <deque> template <typen ...
- HTTP协议通信过程
1. 了解HTTP HTTP(HyperText Transfer Protocol)是一套计算机通过网络进行通信的规则.计算机专家设计出HTTP,使HTTP客户(如Web浏览器)能够从HTTP服务器 ...
- Java检查异常、非检查异常、运行时异常、非运行时异常的区别
Java把所有的非正常情况分为两种:异常(Exception)和错误(Error),它们都继承Throwable父类. Java的异常(Exception和Error)分为检查异常和非检查的异常. 其 ...
- vue 实战
vue 实战 Vue命令行工具vue-cli https://www.cnblogs.com/xiaohuochai/p/7277771.html https://github.com/ymblog/ ...