aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/lib/Reaction.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/lib/Reaction.js')
-rw-r--r--src/stores/lib/Reaction.js14
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';
4export default class Reaction { 4export 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}