diff options
Diffstat (limited to 'src/stores/lib/Store.js')
-rw-r--r-- | src/stores/lib/Store.js | 44 |
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 @@ | |||
1 | import { computed, observable } from 'mobx'; | ||
2 | import Reaction from './Reaction'; | ||
3 | |||
4 | export 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 | } | ||