#32 Preparing storage provider

This commit is contained in:
Serraniel 2020-11-07 16:20:50 +01:00
parent 147b2d8dd1
commit 1dff60dc3b
Signed by: Serraniel
GPG key ID: 3690B4E7364525D3

View file

@ -0,0 +1,53 @@
const { assigned } = require("../utils/helpers")
class StorageProviderChromium {
storeData(key, value, callback) {
}
getData(key, defaultValue, callback) {
}
getStorage() {
if (assigned(chrome.storage.sync)) {
return chrome.storage.sync;
}
return chrome.storage.local;
}
}
class StorageProviderFirefox {
storeData(key, value, callback) {
}
getData(key, defaultValue, callback) {
}
getStorage() {
}
}
let __storageProvieder = undefined;
function createStorageProvider() {
// chrome based browser
if (assigned(chrome?.app)) {
__storageProvieder = new StorageProviderChromium();
}
// firefox
else {
__storageProvieder = new StorageProviderFirefox();
}
}
export function globalStorageProvider() {
if (!assigned(__storageProvieder)) {
createStorageProvider();
}
return __storageProvieder;
}