Last active
November 24, 2016 09:02
-
-
Save JacksonTian/5084165 to your computer and use it in GitHub Desktop.
循环异步调用
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var After = function (callback) { | |
this.index = 0; | |
this.counter = 0; | |
this.results = []; | |
this.callback = callback; | |
}; | |
After.prototype.group = function (callback) { | |
var that = this; | |
var index = that.index; | |
that.index++; | |
return function (data) { | |
that.counter++; | |
that.results[index] = callback ? allback(data) : data; | |
if (that.counter >= that.index) { | |
that.callback(that.results); | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
所以原有代码只要稍作改动就可以了:)