diff options
author | Dominik Guzei <dominik.guzei@gmail.com> | 2019-04-12 12:12:25 +0200 |
---|---|---|
committer | Dominik Guzei <dominik.guzei@gmail.com> | 2019-04-12 12:12:25 +0200 |
commit | 70ed64197835377ef701d2ee80830a50cfec93b4 (patch) | |
tree | 30841b41db1670a625cd744adc8b576fe7bc7875 /src/features/utils/FeatureStore.js | |
parent | disable autofocus on create workspace input for free users (diff) | |
download | ferdium-app-70ed64197835377ef701d2ee80830a50cfec93b4.tar.gz ferdium-app-70ed64197835377ef701d2ee80830a50cfec93b4.tar.zst ferdium-app-70ed64197835377ef701d2ee80830a50cfec93b4.zip |
improve starting and stopping logic for workspace actions and reactions
Diffstat (limited to 'src/features/utils/FeatureStore.js')
-rw-r--r-- | src/features/utils/FeatureStore.js | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/features/utils/FeatureStore.js b/src/features/utils/FeatureStore.js index 48962561d..d863f7464 100644 --- a/src/features/utils/FeatureStore.js +++ b/src/features/utils/FeatureStore.js | |||
@@ -5,38 +5,40 @@ export class FeatureStore { | |||
5 | 5 | ||
6 | _reactions = null; | 6 | _reactions = null; |
7 | 7 | ||
8 | stop() { | ||
9 | this._stopActions(); | ||
10 | this._stopReactions(); | ||
11 | } | ||
12 | |||
13 | // ACTIONS | ||
14 | |||
8 | _registerActions(actions) { | 15 | _registerActions(actions) { |
9 | this._actions = []; | 16 | this._actions = []; |
10 | actions.forEach(a => this._actions.push(a)); | 17 | actions.forEach(a => this._actions.push(a)); |
11 | this._startListeningToActions(); | 18 | this._startActions(this._actions); |
12 | } | 19 | } |
13 | 20 | ||
14 | _startListeningToActions() { | 21 | _startActions(actions = this._actions) { |
15 | this._stopListeningToActions(); | 22 | actions.forEach(a => a[0].listen(a[1])); |
16 | this._actions.forEach(a => a[0].listen(a[1])); | ||
17 | } | 23 | } |
18 | 24 | ||
19 | _stopListeningToActions() { | 25 | _stopActions(actions = this._actions) { |
20 | this._actions.forEach(a => a[0].off(a[1])); | 26 | actions.forEach(a => a[0].off(a[1])); |
21 | } | 27 | } |
22 | 28 | ||
29 | // REACTIONS | ||
30 | |||
23 | _registerReactions(reactions) { | 31 | _registerReactions(reactions) { |
24 | this._reactions = []; | 32 | this._reactions = []; |
25 | reactions.forEach(r => this._reactions.push(new Reaction(r))); | 33 | reactions.forEach(r => this._reactions.push(new Reaction(r))); |
26 | this._startReactions(); | 34 | this._startReactions(this._reactions); |
27 | } | 35 | } |
28 | 36 | ||
29 | _startReactions() { | 37 | _startReactions(reactions = this._reactions) { |
30 | this._stopReactions(); | 38 | reactions.forEach(r => r.start()); |
31 | this._reactions.forEach(r => r.start()); | ||
32 | } | ||
33 | |||
34 | _stopReactions() { | ||
35 | this._reactions.forEach(r => r.stop()); | ||
36 | } | 39 | } |
37 | 40 | ||
38 | stop() { | 41 | _stopReactions(reactions = this._reactions) { |
39 | this._stopListeningToActions(); | 42 | reactions.forEach(r => r.stop()); |
40 | this._stopReactions(); | ||
41 | } | 43 | } |
42 | } | 44 | } |