import { debounce } from "lodash";
import { User } from "user/domain/userEntity";
import { UserStore } from "../domain/userStore";

type GetUserStore = Pick<UserStore, "loadUser">;


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

const getUserUseCase = (store: GetUserStore): Promise<User> | undefined => {
  return deboucedTask(() => store.loadUser());
}

export {getUserUseCase};