Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

354 B
Raw Blame
import type { Ref } from "vue";

type TreeState = Record<string, boolean>;

const store: Record<string, Ref<TreeState>> = {};

export function newTreeKey(): string {
  return Math.random().toString(36).substring(2);
}

export function useTreeState(key: string): Ref<TreeState> {
  if (!store[key]) {
    store[key] = ref({});
  }

  return store[key];
}