diff options
Diffstat (limited to 'src/stores/lib/Reaction.js')
-rw-r--r-- | src/stores/lib/Reaction.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/stores/lib/Reaction.js b/src/stores/lib/Reaction.js index b123ec01c..f2642908f 100644 --- a/src/stores/lib/Reaction.js +++ b/src/stores/lib/Reaction.js | |||
@@ -1,4 +1,3 @@ | |||
1 | // @flow | ||
2 | import { autorun } from 'mobx'; | 1 | import { autorun } from 'mobx'; |
3 | 2 | ||
4 | export default class Reaction { | 3 | export default class Reaction { |
@@ -15,14 +14,18 @@ export default class Reaction { | |||
15 | start() { | 14 | start() { |
16 | if (!this.isRunning) { | 15 | if (!this.isRunning) { |
17 | this.dispose = autorun(() => this.reaction()); | 16 | this.dispose = autorun(() => this.reaction()); |
18 | this.isRunning = true; | 17 | this.isActive = true; |
19 | } | 18 | } |
20 | } | 19 | } |
21 | 20 | ||
22 | stop() { | 21 | stop() { |
23 | if (this.isRunning) { | 22 | if (this.isRunning) { |
24 | this.dispose(); | 23 | this.dispose(); |
25 | this.isRunning = true; | 24 | this.isActive = false; |
26 | } | 25 | } |
27 | } | 26 | } |
28 | } | 27 | } |
28 | |||
29 | export const createReactions = reactions => ( | ||
30 | reactions.map(r => new Reaction(r)) | ||
31 | ); | ||