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