UNPKG

datadog-ux-utils

Version:

Datadog RUM focused UX & performance toolkit: API guards (retry, breaker, rate), React telemetry (error boundary, profiler, Suspense), web vitals & resource observers, offline queues.

30 lines (29 loc) 1.01 kB
import { ApiRateGuard } from '../api/rateGuard.ts'; export type UseGuardedFetchOptions = { onBlocked?: (info: { key: string; until: number; windowMs: number; maxRequests: number; }) => void; /** * If 'wait', automatically retry once after the block window ends. * If 'none', do not retry. * Default: 'none' */ retryAfter?: "wait" | "none"; /** * Optional signal to cancel the auto-retry wait (e.g., route change) */ cancelSignal?: AbortSignal; }; /** * A thin wrapper that uses ApiRateGuard for fetch() calls and * gives you a single place to react to runaway bursts. * * Usage: * const guardedFetch = useGuardedFetch(apiGuard, { onBlocked: showToast }); * const resp = await guardedFetch('/api/items'); */ export declare function useGuardedFetch(guard: ApiRateGuard, opts?: UseGuardedFetchOptions): (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>; //# sourceMappingURL=useGuardFetch.d.ts.map