aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/lib/Store.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-10-13 12:29:40 +0200
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-10-13 12:29:40 +0200
commit58cda9cc7fb79ca9df6746de7f9662bc08dc156a (patch)
tree1211600c2a5d3b5f81c435c6896618111a611720 /src/stores/lib/Store.js
downloadferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.gz
ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.zst
ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.zip
initial commit
Diffstat (limited to 'src/stores/lib/Store.js')
-rw-r--r--src/stores/lib/Store.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/stores/lib/Store.js b/src/stores/lib/Store.js
new file mode 100644
index 000000000..873da7b37
--- /dev/null
+++ b/src/stores/lib/Store.js
@@ -0,0 +1,44 @@
1import { computed, observable } from 'mobx';
2import Reaction from './Reaction';
3
4export default class Store {
5 stores = {};
6 api = {};
7 actions = {};
8
9 _reactions = [];
10
11 // status implementation
12 @observable _status = null;
13 @computed get actionStatus() {
14 return this._status || [];
15 }
16 set actionStatus(status) {
17 this._status = status;
18 }
19
20 constructor(stores, api, actions) {
21 this.stores = stores;
22 this.api = api;
23 this.actions = actions;
24 }
25
26 registerReactions(reactions) {
27 reactions.forEach(reaction => this._reactions.push(new Reaction(reaction)));
28 }
29
30 setup() {}
31
32 initialize() {
33 this.setup();
34 this._reactions.forEach(reaction => reaction.start());
35 }
36
37 teardown() {
38 this._reactions.forEach(reaction => reaction.stop());
39 }
40
41 resetStatus() {
42 this._status = null;
43 }
44}