MCPcopy Index your code
hub / github.com/msgbyte/tailchat / useAsyncRequest

Function useAsyncRequest

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

Source from the content-addressed store, hash-verified

4import { useAsyncFn } from './useAsyncFn';
5
6export function useAsyncRequest<T extends FunctionReturningPromise>(
7 fn: T,
8 deps: DependencyList = []
9) {
10 const [{ loading, value }, call] = useAsyncFn(async (...args: any[]) => {
11 try {
12 return await fn(...args);
13 } catch (err) {
14 // showErrorToasts(isDevelopment ? err : t('系统忙, 请稍后再试'));
15 showErrorToasts(err); // 暂时放开所有错误抛出,正确的做法应该是仅对于内置代码相关的逻辑显示placeholder报错
16 console.error('[useAsyncRequest] error:', err);
17 }
18 }, deps);
19
20 return [{ loading, value }, call as T] as const;
21}

Callers 15

useUserSettingsFunction · 0.90
useConverseMessageFunction · 0.85
ManualInstall.tsxFile · 0.85
Item.tsxFile · 0.85
ImageUploader.tsxFile · 0.85
CreateGroup.tsxFile · 0.85
getFieldsFunction · 0.85
ModifyPassword.tsxFile · 0.85
EmailVerify.tsxFile · 0.85

Calls 4

useAsyncFnFunction · 0.90
showErrorToastsFunction · 0.90
errorMethod · 0.80
fnFunction · 0.50

Tested by

no test coverage detected