import { Ref, ref } from 'vue'; import { defineStore } from 'pinia'; import { IResults } from '@/database/results/results.types'; import { ResultsGateway } from '@/database/results/results.gateway'; interface State { results: Ref; } export const useResultsStore = defineStore('results', () => { const state: State = { results: ref({} as IResults.Result[]), }; const actions = { async getResults() { if (!state.results.value.length) { state.results.value = await ResultsGateway.getResults(); } }, }; return { ...state, ...actions, }; });