From a26d8a8a1bed48a77e062914c120a23ace7bb8cf Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 24 Feb 2019 20:54:35 +0900 Subject: Capitalize background scripts --- src/background/repositories/SettingRepository.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/background/repositories/SettingRepository.js (limited to 'src/background/repositories/SettingRepository.js') diff --git a/src/background/repositories/SettingRepository.js b/src/background/repositories/SettingRepository.js new file mode 100644 index 0000000..c4667a9 --- /dev/null +++ b/src/background/repositories/SettingRepository.js @@ -0,0 +1,23 @@ +import MemoryStorage from '../infrastructures/MemoryStorage'; + +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); + } +} -- cgit v1.2.3