Closure IndexedDB. , IDB .
, .
:
goog.db.openDatabase('mydb', 1, function(ev, db, tx) {
db.createObjectStore('mystore');
}).addCallback(function(db) {
var putTx = db.createTransaction(
[],
goog.db.Transaction.TransactionMode.READ_WRITE);
var store = putTx.objectStore('mystore');
store.put('value', 'key');
goog.listen(putTx, goog.db.Transaction.EventTypes.COMPLETE, function() {
var getTx = db.createTransaction([]);
var request = getTx.objectStore('mystore').get('key');
request.addCallback(function(result) {
...
});
});
, API , , , IndexedDB wrapper, .
, . , : 1) db 2) 3) .
, db , .
Basically, I combine these three promises into one promise in my library.
source
share