usePromise
Easily observe asynchronous processes
Last updated
Was this helpful?
Was this helpful?
import { usePromise } from "atomico";
const getUsers = (id: number) => Promise.resolve({ id, name: "Atomico" });
function component() {
const promise = usePromise(getUsers, [1]);
return (
<host>
{promise.fulfilled ? (
<h1>Done {promise.result.name}!</h1>
) : promise.pending ? (
<h1>Loading...</h1>
) : (
<h1>Error!</h1>
)}
</host>
);
}