diff options
Diffstat (limited to 'src/background/repositories/setting.js')
-rw-r--r-- | src/background/repositories/setting.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/background/repositories/setting.js b/src/background/repositories/setting.js new file mode 100644 index 0000000..6d48525 --- /dev/null +++ b/src/background/repositories/setting.js @@ -0,0 +1,23 @@ +import MemoryStorage from '../infrastructures/memory-storage'; + +const CACHED_SETTING_KEY = 'setting'; + +export default class SettingRepository { + constructor() { + this.cache = new MemoryStorage(); + } + + get() { + return Promise.resolve(this.cache.get(CACHED_SETTING_KEY)); + } + + update(value) { + return this.cache.set(CACHED_SETTING_KEY, value); + } + + async setProperty(name, value) { + let current = await this.get(); + current.properties[name] = value; + return this.update(current); + } +} |