import { IdSuspense } from '../create-hooks.js';
import { usePromise } from './use-promise.js';

/**
 * @type {import("core").UseAsync}
 */
const useAsync = (callback, args) => {
    const status = usePromise(callback, args);

    if (status.pending) {
        throw IdSuspense;
    }
    //@ts-ignore
    return status.result;
};

export { useAsync };
