From cb293c78fc8d6fdf5d778d49a73b9103fbbfa7b1 Mon Sep 17 00:00:00 2001 From: igoradamenko Date: Fri, 2 Feb 2018 20:52:27 +0200 Subject: [PATCH] add store singleton --- web/app/common/store.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 web/app/common/store.js diff --git a/web/app/common/store.js b/web/app/common/store.js new file mode 100644 index 00000000..9950122f --- /dev/null +++ b/web/app/common/store.js @@ -0,0 +1,26 @@ +let _instance; + +class Store { + constructor() { + if (_instance) return _instance; + + this.data = {}; + + _instance = this; + + return _instance; + } + + set(obj) { + this.data = { + ...this.data, + ...obj, + }; + } + + get(key) { + return this.data[key]; + } +} + +export default new Store();