mirror of
https://github.com/localForage/localForage.git
synced 2026-01-25 14:44:26 +00:00
23 lines
659 B
JavaScript
23 lines
659 B
JavaScript
/*globals importScripts:true, self:true */
|
|
importScripts("/dist/localforage.js");
|
|
|
|
self.addEventListener('message', function(e) {
|
|
function handleError(e) {
|
|
self.postMessage({
|
|
error: JSON.stringify(e),
|
|
body: e,
|
|
fail: true
|
|
});
|
|
}
|
|
|
|
localforage.setDriver(e.data.driver, function() {
|
|
localforage.setItem('web worker', e.data.value, function() {
|
|
localforage.getItem('web worker', function(err, value) {
|
|
self.postMessage({
|
|
body: value
|
|
});
|
|
});
|
|
}, handleError).catch(handleError);
|
|
}, handleError);
|
|
}, false);
|