[PCCompat] Rewrite to use seperate global dir and object, other structural changes

This commit is contained in:
Ducko 2021-04-07 16:56:51 +01:00 committed by フズキ
parent 2584ce03c5
commit 61c94f40d3
No known key found for this signature in database
GPG key ID: E06450E46F83376C
8 changed files with 130 additions and 126 deletions

View file

@ -0,0 +1,33 @@
export const settingStores = {};
export const makeStore = (key) => {
settingStores[key] = new SimpleStore();
};
class SimpleStore {
constructor() {
this.store = {};
}
getSetting = (key, defaultValue) => {
return this.store[key] ?? defaultValue;
}
updateSetting = (key, value) => {
if (value === undefined) {
return this.toggleSetting(key);
}
this.store[key] = value;
}
toggleSetting = (key) => {
this.store[key] = !this.store[key];
}
deleteSetting = (key) => {
delete this.store[key];
}
getKeys = () => Object.keys(this.store)
}