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.

20 lines (19 loc) 692 B
import { ApiRateGuard } from '../api/rateGuard.ts'; export type UseGuardedCallOptions = { onBlocked?: (info: { key: string; until: number; windowMs: number; maxRequests: number; }) => void; retryAfter?: "wait" | "none"; }; /** * Guard any async call (Axios, graphql, SDK). * * Usage: * const guardedCall = useGuardedCall(apiGuard, { onBlocked: toast }); * const data = await guardedCall('POST /api/orders', () => axios.post(...)); */ export declare function useGuardedCall(guard: ApiRateGuard, opts?: UseGuardedCallOptions): <T>(key: string, call: () => Promise<T>) => Promise<T | undefined>; //# sourceMappingURL=useGuardedCall.d.ts.map