Created
March 29, 2016 02:09
-
-
Save localnerve/fe8053f3e0d412cfc6eb to your computer and use it in GitHub Desktop.
Snippet to add visionmedia/debug flag to IndexedDB for service-worker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var request = window.indexedDB.open("service-worker", 1); | |
request.onerror = function (event) { | |
console.error('failed to open service-worker database', request.errorCode); | |
}; | |
request.onsuccess = function (event) { | |
var db = event.target.result; | |
var transaction = db.transaction(['state'], 'readwrite'); | |
transaction.onerror = function (event) { | |
console.error('transaction failed on state store'); | |
db.close(); | |
}; | |
var stateStore = transaction.objectStore('state'); | |
var putRequest = stateStore.put('*', 'debug'); | |
putRequest.onerror = function (event) { | |
console.error('stateStore put failed'); | |
db.close(); | |
}; | |
putRequest.onsuccess = function (event) { | |
console.log('stateStore put succeeded'); | |
db.close(); | |
} | |
}; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run in main context for window reference