Methods
(static) next(callback)
开始执行异步队列
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | 嵌套时的回调函数,其实就是hui.Flow.prototype.next |
- Source:
(static) push(fn) → {this}
添加需要异步执行的函数
Parameters:
Name | Type | Description |
---|---|---|
fn |
function | 需要异步执行的函数 |
- Source:
Returns:
返回主体以便于后续操作
- Type
- this
Example
function doit() {
alert('a');
var que1 = new hui.Flow();
que1.push(a);
que1.push(d);
setTimeout(function(){
que1.next();
},400);
}
function a(callback) {
alert('a');
var que2 = new hui.Flow();
que2.push(b).push(c).push(callback);
setTimeout(function(){
que2.next();
},400);
}
function b(callback) {
alert('b');
callback&&callback();
}
function c(callback) {
alert('c');
callback&&callback();
}