diff options
Diffstat (limited to 'src/features/utils/FeatureStore.ts')
-rw-r--r-- | src/features/utils/FeatureStore.ts | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/features/utils/FeatureStore.ts b/src/features/utils/FeatureStore.ts new file mode 100644 index 000000000..2bdd167f3 --- /dev/null +++ b/src/features/utils/FeatureStore.ts | |||
@@ -0,0 +1,48 @@ | |||
1 | import Reaction from '../../stores/lib/Reaction'; | ||
2 | |||
3 | export default class FeatureStore { | ||
4 | _actions: any = []; | ||
5 | |||
6 | _reactions: Reaction[] = []; | ||
7 | |||
8 | stop() { | ||
9 | this._stopActions(); | ||
10 | this._stopReactions(); | ||
11 | } | ||
12 | |||
13 | // ACTIONS | ||
14 | _registerActions(actions) { | ||
15 | this._actions = actions; | ||
16 | this._startActions(); | ||
17 | } | ||
18 | |||
19 | _startActions(actions = this._actions) { | ||
20 | for (const action of actions) { | ||
21 | action.start(); | ||
22 | } | ||
23 | } | ||
24 | |||
25 | _stopActions(actions = this._actions) { | ||
26 | for (const action of actions) { | ||
27 | action.stop(); | ||
28 | } | ||
29 | } | ||
30 | |||
31 | // REACTIONS | ||
32 | _registerReactions(reactions) { | ||
33 | this._reactions = reactions; | ||
34 | this._startReactions(); | ||
35 | } | ||
36 | |||
37 | _startReactions(reactions = this._reactions) { | ||
38 | for (const reaction of reactions) { | ||
39 | reaction.start(); | ||
40 | } | ||
41 | } | ||
42 | |||
43 | _stopReactions(reactions = this._reactions) { | ||
44 | for (const reaction of reactions) { | ||
45 | reaction.stop(); | ||
46 | } | ||
47 | } | ||
48 | } | ||