Interval Looper

非同步数组枚举回调

As of 2014-07-25. See the latest version.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/3588/10916/Interval%20Looper.js

Author
Jixun.Moe
Version
0.0.1.20140725060155
Created
2014-07-24
Updated
2014-07-25
License
N/A

数组循环

// 用法:
var loop = new IntervalLoop ([1, 2, 3], function (next, item) {
	$.ajax ({
		url: 'http://example.com/?id=' + item
	}).success (function (r) {
		// TODO: 处理抓取的数据
		// ...
		
		next ();
	});
}, 500).add (1, 2, 3).add (999).loop ();
 
// 监听事件更新
var xyz = document.addEventListener ('xyz', function (eve) {
	// TODO: 解析数据并传递需要的值
	loop.add(eve.target);
}, false);