import { defineStore } from "pinia";
import { ref } from 'vue';


export const useWsStore = defineStore("wsData", () => {
  const data1 = ref({ test: 'hello world'});
  const data2 = ref({});
  const data3 = ref({});

  function updateData(category, data) {
    console.log('update', data)
    switch (category) {
      case "1":
        data1.value = data;
        break;
      case "2":
        data2.value = data;
        break;
      case "3":
        data3.value = data;
      default:
        break;
    }
  }

  return { data1, data2, data3, updateData };
});
// export const useWsStore = defineStore('wsData', {
//     state: () => ({
//         data1: {
//             test: 'hello world'
//         },
//         data2: null,
//         data3: null,
//     }),
//     actions: {
//         updateData(category, data) {
//             this[category] = data
//         }
//     }
// })
