From 52211095aab71f8b59b093b19ae34c222be9f390 Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Thu, 14 Oct 2021 09:32:20 +0200 Subject: chore: convert various JS to TS (#2062) --- src/stores/lib/Reaction.js | 31 ------------------------------- src/stores/lib/Reaction.ts | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 31 deletions(-) delete mode 100644 src/stores/lib/Reaction.js create mode 100644 src/stores/lib/Reaction.ts (limited to 'src/stores') diff --git a/src/stores/lib/Reaction.js b/src/stores/lib/Reaction.js deleted file mode 100644 index 7e1bc685e..000000000 --- a/src/stores/lib/Reaction.js +++ /dev/null @@ -1,31 +0,0 @@ -import { autorun } from 'mobx'; - -export default class Reaction { - reaction; - - isRunning = false; - - dispose; - - constructor(reaction) { - this.reaction = reaction; - } - - start() { - if (!this.isRunning) { - this.dispose = autorun(this.reaction); - this.isRunning = true; - } - } - - stop() { - if (this.isRunning) { - this.dispose(); - this.isRunning = false; - } - } -} - -export const createReactions = (reactions) => ( - reactions.map((r) => new Reaction(r)) -); diff --git a/src/stores/lib/Reaction.ts b/src/stores/lib/Reaction.ts new file mode 100644 index 000000000..0ca24a6fa --- /dev/null +++ b/src/stores/lib/Reaction.ts @@ -0,0 +1,29 @@ +import { autorun } from 'mobx'; + +export default class Reaction { + reaction; + + isRunning = false; + + dispose; + + constructor(reaction) { + this.reaction = reaction; + } + + start() { + if (!this.isRunning) { + this.dispose = autorun(this.reaction); + this.isRunning = true; + } + } + + stop() { + if (this.isRunning) { + this.dispose?.(); + this.isRunning = false; + } + } +} + +export const createReactions = reactions => reactions.map(r => new Reaction(r)); -- cgit v1.2.3-70-g09d2