MCPcopy Create free account
hub / github.com/msgbyte/tailchat / useAsync

Function useAsync

client/shared/hooks/useAsync.ts:7–29  ·  view source on GitHub ↗
(
  fn: T,
  deps: DependencyList = []
)

Source from the content-addressed store, hash-verified

5// Reference: https://github.com/streamich/react-use/blob/master/src/useAsync.ts
6
7export function useAsync<T extends FunctionReturningPromise>(
8 fn: T,
9 deps: DependencyList = []
10) {
11 const [state, callback] = useAsyncFn(fn, deps, {
12 loading: true,
13 });
14 const lockRef = useRef(false);
15
16 useEffect(() => {
17 if (lockRef.current === true) {
18 return;
19 }
20
21 if (deps.length === 0) {
22 lockRef.current = true;
23 }
24
25 callback();
26 }, [callback]);
27
28 return state;
29}

Callers 15

useConverseMessageFunction · 0.90
useUserInfoListFunction · 0.90
useCachedUserInfoFunction · 0.90
useDMConverseNameFunction · 0.85
App.tsxFile · 0.85
usePluginStoreDataFunction · 0.85
useDMConverseActionsFunction · 0.85
useAppStateFunction · 0.85
Message.tsxFile · 0.85

Calls 2

useAsyncFnFunction · 0.90
callbackFunction · 0.50

Tested by

no test coverage detected