useEntityManager.ts 504 B

123456789101112131415
  1. import { useRepo } from "pinia-orm";
  2. import EntityManager from "~/services/data/entityManager";
  3. import { useMaestroRequestService } from "~/composables/data/useMaestroRequestService";
  4. let entityManager: EntityManager | null = null;
  5. export const useEntityManager = () => {
  6. if (entityManager === null) {
  7. const { apiRequestService } = useMaestroRequestService();
  8. const getRepo = useRepo;
  9. entityManager = new EntityManager(apiRequestService, getRepo);
  10. }
  11. return { em: entityManager };
  12. };