diff options
author | 2019-04-12 12:12:25 +0200 | |
---|---|---|
committer | 2019-04-12 12:12:25 +0200 | |
commit | 70ed64197835377ef701d2ee80830a50cfec93b4 (patch) | |
tree | 30841b41db1670a625cd744adc8b576fe7bc7875 /src/stores/lib/Reaction.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/stores/lib/Reaction.js')
-rw-r--r-- | src/stores/lib/Reaction.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/stores/lib/Reaction.js b/src/stores/lib/Reaction.js index 46aa4dae6..b123ec01c 100644 --- a/src/stores/lib/Reaction.js +++ b/src/stores/lib/Reaction.js | |||
@@ -4,21 +4,25 @@ import { autorun } from 'mobx'; | |||
4 | export default class Reaction { | 4 | export default class Reaction { |
5 | reaction; | 5 | reaction; |
6 | 6 | ||
7 | hasBeenStarted; | 7 | isRunning = false; |
8 | 8 | ||
9 | dispose; | 9 | dispose; |
10 | 10 | ||
11 | constructor(reaction) { | 11 | constructor(reaction) { |
12 | this.reaction = reaction; | 12 | this.reaction = reaction; |
13 | this.hasBeenStarted = false; | ||
14 | } | 13 | } |
15 | 14 | ||
16 | start() { | 15 | start() { |
17 | this.dispose = autorun(() => this.reaction()); | 16 | if (!this.isRunning) { |
18 | this.hasBeenStarted = true; | 17 | this.dispose = autorun(() => this.reaction()); |
18 | this.isRunning = true; | ||
19 | } | ||
19 | } | 20 | } |
20 | 21 | ||
21 | stop() { | 22 | stop() { |
22 | if (this.hasBeenStarted) this.dispose(); | 23 | if (this.isRunning) { |
24 | this.dispose(); | ||
25 | this.isRunning = true; | ||
26 | } | ||
23 | } | 27 | } |
24 | } | 28 | } |