确定何时完成 JavaScript Dropbox 数据存储 API 的插入
Determining When the JavaScript Dropbox Datastore API is Done Inserting
我正在使用JavaScript API将大量记录(2000-3000)导入到Dropbox数据存储中。我试图阻止 UI,直到导入完成,因为如果用户离开页面,导入将终止部分。
这是我的代码,其中包含对正在发生的事情的注释:
//This shows a "loading" spinner
showLoader('Standby','Importing logbook...');
//Fire import function
writeToDropbox('aircraft', data.aircraft);
function writeToDropbox(tableName, dataArray){
//Write up to 100 items per delta
for(var i = 0; i < dataArray.length && i < 100; i++) {
//Write to Dropbox
datastore.getTable(tableName).insert(dataArray[i]);
}
if(i < dataArray.length) {
//More to write
window.setTimeout(function(){
//After a tick, continue from where we left off
writeToDropbox(tableName, dataArray.slice(i));
}, 1);
}
//Check progress
if(dataArray.length == 0){
//Writing complete... show the confirmation modal
hideLoader();
$('#modal-done').show(); //(!) This happens before all the records are inserted
}
}
我遇到的问题是 JavaScript 全部执行并且我的应用程序显示确认模式,但在后台数据存储 API 仍在插入记录。
如何可靠地确定 API 何时完成插入记录?
请参阅 https://www.dropbox.com/developers/blog/61/checking-the-datastore-sync-status-in-javascript。
检查datastore.getSyncStatus().uploading
。
相关文章:
- 在页面卸载时写入HTML5 FileSystem API存储
- javascript api,用于在第三方域上存储身份验证令牌
- Chrome存储API无法使用内容脚本
- 如何将Facebook Graph API响应存储为Javascript数组
- 如何使用 github api 查找最新的存储库
- 围绕web存储的Javascript API包装器
- html5文件api,将用户选择的目录存储在sessionStorage中
- 如何存储推特搜索API推文并转发它们
- 正在尝试上载使用HTML5Fileneneneba API存储的文件
- 确定何时完成 JavaScript Dropbox 数据存储 API 的插入
- 使用 chrome 存储 API 从本地存储中存储和检索数据
- FirefoxOS:使用设备存储api返回数组
- Firefox插件sdk:如何在内容脚本中使用简单存储API
- 如何从chrome扩展's存储api访问多个键
- 在HTML5 LocalStorage中存储API凭据
- 变量won't在chrome应用中使用chrome存储API更新
- 哪个(如果有的话)Javascript存储API (Google Drive, Dropbox, OneDrive)提供
- 相当于无需重启的firefox扩展的简单存储API
- chrome扩展存储api获胜't设置数组
- 在chrome存储API集合调用中使用的密钥是否可以是变量