mirror of
https://github.com/ilyakooo0/purescript-indexedDB.git
synced 2024-09-11 06:55:48 +03:00
fix onBlocked callback -> request not ready, so no db accessible
This commit is contained in:
parent
16d379d6cd
commit
7e71fe18ab
@ -18,12 +18,6 @@ exports.errorHandler = function errorHandler(cb) {
|
||||
};
|
||||
};
|
||||
|
||||
exports.eventHandler = function eventHandler(cb) {
|
||||
return function _handler(e) {
|
||||
cb(e.target.result)();
|
||||
};
|
||||
};
|
||||
|
||||
exports._showIDBDatabase = function _showIDBDatabase(db) {
|
||||
return '(IDBDatabase ' +
|
||||
'{ name: ' + db.name +
|
||||
|
@ -1,8 +1,8 @@
|
||||
const $Core = require('Database.IndexedDB.Core/foreign');
|
||||
|
||||
const noOp = $Core.noOp;
|
||||
const noOp2 = $Core.noOp2;
|
||||
const errorHandler = $Core.errorHandler;
|
||||
const eventHandler = $Core.eventHandler;
|
||||
|
||||
|
||||
exports.deleteDatabase = function deleteDatabase(name) {
|
||||
@ -26,8 +26,14 @@ exports._open = function _open(fromMaybe, name, mver, req) {
|
||||
success(e.target.result);
|
||||
};
|
||||
|
||||
request.onblocked = function onBlocked() {
|
||||
fromMaybe(noOp)(req.onBlocked)();
|
||||
};
|
||||
|
||||
request.onupgradeneeded = function onUpgradeNeeded(e) {
|
||||
fromMaybe(noOp2)(req.onUpgradeNeeded)(e.target.result)();
|
||||
};
|
||||
|
||||
request.onerror = errorHandler(error);
|
||||
request.onblocked = eventHandler(fromMaybe(noOp2)(req.onBlocked));
|
||||
request.onupgradeneeded = eventHandler(fromMaybe(noOp2)(req.onUpgradeNeeded));
|
||||
};
|
||||
};
|
||||
|
@ -13,7 +13,7 @@ import Database.IndexedDB.Core
|
||||
|
||||
|
||||
type IDBOpenRequest eff =
|
||||
{ onBlocked :: Maybe (IDBDatabase -> Eff (idb :: INDEXED_DB | eff) Unit)
|
||||
{ onBlocked :: Maybe (Eff (idb :: INDEXED_DB | eff) Unit)
|
||||
, onUpgradeNeeded :: Maybe (IDBDatabase -> Eff (idb :: INDEXED_DB | eff) Unit)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user