feat: start/stop engine (WIP)

This commit is contained in:
Settel 2022-07-31 23:33:03 +02:00
parent 43f5a43202
commit d9ebd90c12

View File

@ -1,16 +1,30 @@
import { useState } from '#app'
export interface useEngine {
start(): void
stop(): void
}
export default (): useEngine => {
const isActive = useState('engine__is-active', () => false)
const shouldStop = useState('engine__should-stop', () => false)
return {
start: (): void => {
if (isActive.value && !shouldStop.value) {
console.warn('attempt to start already running engine!')
return
}
isActive.value = true
shouldStop.value = false
console.log('start engine')
},
stop: (): void => {
console.log('stop engine')
if (isActive.value) {
shouldStop.value = true
console.log('shut down engine')
}
},
}
}