import { debounce } from "lodash";
import { ServicesStore } from "services/domain/servicesStore";

type LoadServicesStore = Pick<ServicesStore, "loadServices">;

const deboucedTask = debounce((task) => Promise.resolve(task()), 500);

const loadServicesUseCase = (store: LoadServicesStore) => {
  return deboucedTask(() => store.loadServices());
};

export { loadServicesUseCase };
