使用法を勉強していますseries.js
。簡単な例を書きasync.series
ました-3つの関数を実行します。好奇心から、コールバック呼び出しの前後にログ出力を作成しました。私にとって予期しないことに、「コールバック後」のログメッセージはありません。
私の質問は-それはメモリリークですか、そしてこれらの呼び出しはまだスタックにあり、戻るのを待っていますか?またはasync.js
、コールバック後に関数をカットするための特別なメカニズムを使用しますか?async.js
ソースを読み込もうとしましたが、何も見つかりませんでした。
何かアイデアはありますか?
テストページ:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>My Page</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript" src="https://raw.github.com/caolan/async/master/lib/async.js"></script>
<script type="text/javascript">
var a = function (callback) {
console.log('a before callback');
return callback(null);
console.log('a after callback');
};
var b = function (callback) {
console.log('b before callback');
return callback(null);
console.log('b after callback');
};
var c = function (callback) {
console.log('c before callback');
return callback(null);
console.log('c after callback');
};
var doit = function() {
console.log('click');
async.series([a, b, c, a, b, c], function(something) {console.log('async.series happy end: '+something);});
console.log('series finished');
};
$(function() {
$('#bu').click(doit);
});
console.log('hello');
</script>
</head>
<body id="bo" class="blue">
<input type="button" id="bu" value="click"><br />
</body>
</html>
ログ出力:
hello
event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future.
click
a before callback
b before callback
c before callback
a before callback
b before callback
c before callback
async.series happy end: null
series finished