import { useEffect } from "atomico";
import { toastrMessage } from "../../components/kun-editor/extenstions/extensions/exec-toastr";

export function useAsyncHook<T>(data: () => Promise<T>, args?: unknown[]): void {
  useEffect(() => {
    data().then((r1) => {
      console.log(r1);
    }).catch((e) => {
      toastrMessage(e);
    });
  }, args ?? []);
}
