[英]Doubts about HTML5 IndexedDB Async API
While reading the HTML5 IndexedDB Specification I had some doubts about its asynchronous request model. 在阅读HTML5 IndexedDB规范时,我对其异步请求模型有一些疑问。 When looking at the request api example , the
open
method is used to start an async request. 在查看请求api示例时 ,
open
方法用于启动异步请求。
var request = indexedDB.open('AddressBook', 'Address Book');
request.onsuccess = function(evt) {...};
request.onerror = function(evt) {...};
At the time this request is started, there are no event handlers defined yet. 在启动此请求时,尚未定义事件处理程序。
open
method succeeds before the javascript interpreter executes the assignment to onsuccess
? onsuccess
的赋值之前open
方法成功,会发生什么? In my opinion an api like the following would be much more logical: 在我看来,如下所示的api更加合乎逻辑:
db.open('AddressBook', 'Address Book', {
onsuccess: function(e) { ... },
onerror : function(e) { ... }
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.