From 70ed64197835377ef701d2ee80830a50cfec93b4 Mon Sep 17 00:00:00 2001 From: Dominik Guzei Date: Fri, 12 Apr 2019 12:12:25 +0200 Subject: improve starting and stopping logic for workspace actions and reactions --- src/stores/lib/Reaction.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/stores/lib') 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'; export default class Reaction { reaction; - hasBeenStarted; + isRunning = false; dispose; constructor(reaction) { this.reaction = reaction; - this.hasBeenStarted = false; } start() { - this.dispose = autorun(() => this.reaction()); - this.hasBeenStarted = true; + if (!this.isRunning) { + this.dispose = autorun(() => this.reaction()); + this.isRunning = true; + } } stop() { - if (this.hasBeenStarted) this.dispose(); + if (this.isRunning) { + this.dispose(); + this.isRunning = true; + } } } -- cgit v1.2.3-54-g00ecf