refactor: split engine methods into separate files
This commit is contained in:
parent
0b406595c7
commit
db79d45217
@ -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')
|
||||
}
|
||||
}
|
@ -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<boolean>
|
||||
@ -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),
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user