mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-04-29 20:20:16 +00:00
Initial commit of eigent-main
This commit is contained in:
commit
723df5a03e
1144 changed files with 103478 additions and 0 deletions
23
package/@stackframe/stack-shared/dist/esm/hooks/use-async-external-store.js
vendored
Normal file
23
package/@stackframe/stack-shared/dist/esm/hooks/use-async-external-store.js
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// src/hooks/use-async-external-store.tsx
|
||||
import { useEffect, useState } from "react";
|
||||
import { AsyncResult } from "../utils/results";
|
||||
function useAsyncExternalStore(subscribe) {
|
||||
const [isAvailable, setIsAvailable] = useState(false);
|
||||
const [value, setValue] = useState();
|
||||
useEffect(() => {
|
||||
const unsubscribe = subscribe((value2) => {
|
||||
setValue(() => value2);
|
||||
setIsAvailable(() => true);
|
||||
});
|
||||
return unsubscribe;
|
||||
}, [subscribe]);
|
||||
if (isAvailable) {
|
||||
return AsyncResult.ok(value);
|
||||
} else {
|
||||
return AsyncResult.pending();
|
||||
}
|
||||
}
|
||||
export {
|
||||
useAsyncExternalStore
|
||||
};
|
||||
//# sourceMappingURL=use-async-external-store.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue