Skip to content

Instantly share code, notes, and snippets.

@localnerve
Created March 29, 2016 02:09
Show Gist options
  • Save localnerve/fe8053f3e0d412cfc6eb to your computer and use it in GitHub Desktop.
Save localnerve/fe8053f3e0d412cfc6eb to your computer and use it in GitHub Desktop.
Snippet to add visionmedia/debug flag to IndexedDB for service-worker
(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();
}
};
}());
@localnerve
Copy link
Author

Run in main context for window reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment