blob: 8d2fb406683ef521bf2ead0eaad659a60c0a8d70 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import { computed, observable } from 'mobx';
import Reaction from './Reaction';
export default class Store {
stores = {};
api = {};
actions = {};
_reactions = [];
// status implementation
@observable _status = null;
@computed get actionStatus() {
return this._status || [];
}
set actionStatus(status) {
this._status = status;
}
constructor(stores, api, actions) {
this.stores = stores;
this.api = api;
this.actions = actions;
}
registerReactions(reactions) {
reactions.forEach(reaction => this._reactions.push(new Reaction(reaction)));
}
setup() {}
initialize() {
this.setup();
this._reactions.forEach(reaction => reaction.start());
}
teardown() {
this._reactions.forEach(reaction => reaction.stop());
}
resetStatus() {
this._status = null;
}
}
|