atomico
Version:
Atomico is a small library for the creation of interfaces based on web-components, only using functions and hooks.
15 lines (13 loc) • 351 B
JavaScript
import { IdSuspense } from "../create-hooks.js";
import { usePromise } from "../custom-hooks/use-promise.js";
/**
* @type {import("core").UseAsync}
*/
export const useAsync = (callback, args) => {
const status = usePromise(callback, args);
if (status.pending) {
throw IdSuspense;
}
//@ts-ignore
return status.result;
};