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) {
|
if (this.isActive.value && !this.shouldStop.value) {
|
||||||
console.warn('attempt to start already running engine!')
|
console.warn('attempt to start already running engine!')
|
||||||
return
|
return
|
||||||
@ -7,3 +7,10 @@ export default function (): void {
|
|||||||
this.shouldStop.value = false
|
this.shouldStop.value = false
|
||||||
console.log('start engine')
|
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 { useState } from '#app'
|
||||||
import { Ref } from 'vue'
|
import { Ref } from 'vue'
|
||||||
import start from '@/composables/engine/start'
|
import { start, stop } from '@/composables/engine/startStop'
|
||||||
|
|
||||||
interface EngineContext {
|
interface EngineContext {
|
||||||
isActive: Ref<boolean>
|
isActive: Ref<boolean>
|
||||||
@ -20,11 +20,6 @@ export default (): useEngine => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
start: () => start.apply(context),
|
start: () => start.apply(context),
|
||||||
stop: (): void => {
|
stop: () => stop.apply(context),
|
||||||
if (context.isActive.value) {
|
|
||||||
context.shouldStop.value = true
|
|
||||||
console.log('shut down engine')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user