feat: start/stop engine (WIP)
This commit is contained in:
parent
43f5a43202
commit
d9ebd90c12
@ -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')
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user