knowyt/client/src/composables/useEngine.ts

25 lines
582 B
TypeScript

import { useState } from '#app'
import { Ref } from 'vue'
import { start, stop } from '@/composables/engine/startStop'
interface EngineContext {
isActive: Ref<boolean>
shouldStop: Ref<boolean>
}
export interface useEngine {
start(): void
stop(): void
}
export default (): useEngine => {
const context: EngineContext = {
isActive: useState('engine__is-active', () => false),
shouldStop: useState('engine__should-stop', () => false),
}
return {
start: () => start.apply(context),
stop: () => stop.apply(context),
}
}