jsonp-buffered-loader bufferedLoader = function (eleLoaded, loader, callback) { /* 1. eleLoaded (index) 2. loader (start, end) HELP: the loader's callback func will enrich store, and unless passes the checking of bufferedLoader, it will rec
bufferedLoader = function (eleLoaded, loader, callback) {
/*
1. eleLoaded (index)
2. loader (start, end)
HELP: the loader's callback func will enrich store, and unless passes the checking of bufferedLoader,
it will recursively call the bufferedLoader. e.g. loaderCallback (data) { ... fn(i, end) }
NOTE: if there is somehow a terminating condition, you can place it in the loader/loaderCallback, and
manually excute the callback func above.
3. callback - when all of the data is ready
1. eleLoaded (index) 判断每个数据是不是已经加载到了
2. loader (start, end) 迭代加载尚未加载的数据,当有一部分数据还没有加载的话
3. callback () 当所有需要的数据都已经加载到了,才会执行要执行的操作
*/
var fn = function (start, end) {
for (var i = start; i < end; i++) {
if (!eleLoaded(i)) {
loader(i, end);
return;
}
}
callback();
};
return fn;
};
