From db79d452176c38247d151814632966a384d5e67d Mon Sep 17 00:00:00 2001 From: Settel Date: Tue, 2 Aug 2022 22:20:08 +0200 Subject: [PATCH] refactor: split engine methods into separate files --- client/src/composables/engine/{start.ts => startStop.ts} | 9 ++++++++- client/src/composables/useEngine.ts | 9 ++------- 2 files changed, 10 insertions(+), 8 deletions(-) rename client/src/composables/engine/{start.ts => startStop.ts} (57%) diff --git a/client/src/composables/engine/start.ts b/client/src/composables/engine/startStop.ts similarity index 57% rename from client/src/composables/engine/start.ts rename to client/src/composables/engine/startStop.ts index 78b16f2..442126b 100644 --- a/client/src/composables/engine/start.ts +++ b/client/src/composables/engine/startStop.ts @@ -1,4 +1,4 @@ -export default function (): void { +export function start(): void { if (this.isActive.value && !this.shouldStop.value) { console.warn('attempt to start already running engine!') return @@ -7,3 +7,10 @@ export default function (): void { this.shouldStop.value = false console.log('start engine') } + +export function stop(): void { + if (this.isActive.value) { + this.shouldStop.value = true + console.log('shut down engine') + } +} \ No newline at end of file diff --git a/client/src/composables/useEngine.ts b/client/src/composables/useEngine.ts index 8cd99f8..7d22994 100644 --- a/client/src/composables/useEngine.ts +++ b/client/src/composables/useEngine.ts @@ -1,6 +1,6 @@ import { useState } from '#app' import { Ref } from 'vue' -import start from '@/composables/engine/start' +import { start, stop } from '@/composables/engine/startStop' interface EngineContext { isActive: Ref @@ -20,11 +20,6 @@ export default (): useEngine => { return { start: () => start.apply(context), - stop: (): void => { - if (context.isActive.value) { - context.shouldStop.value = true - console.log('shut down engine') - } - }, + stop: () => stop.apply(context), } } \ No newline at end of file