Pacer Docs
API Reference
Debouncer API Reference
- DebouncerOptions
- DebouncerState
- AsyncDebouncerOptions
- AsyncDebouncerState
- debounce
- asyncDebounce
- Debouncer
- AsyncDebouncer
- ReactDebouncerOptions
- ReactAsyncDebouncerOptions
- ReactDebouncer
- ReactAsyncDebouncer
- useDebouncer
- useDebouncedCallback
- useDebouncedState
- useDebouncedValue
- useAsyncDebouncer
- useAsyncDebouncedCallback
Throttler API Reference
- ThrottlerOptions
- ThrottlerState
- AsyncThrottlerOptions
- AsyncThrottlerState
- throttle
- asyncThrottle
- Throttler
- AsyncThrottler
- ReactThrottlerOptions
- ReactAsyncThrottlerOptions
- ReactThrottler
- ReactAsyncThrottler
- useThrottler
- useThrottledCallback
- useThrottledState
- useThrottledValue
- useAsyncThrottler
- useAsyncThrottledCallback
Rate Limiter API Reference
Queue API Reference
AI/LLM: This documentation page is available in plain markdown format at/pacer/latest/docs/reference/functions/asyncRetry.md
asyncRetry
ts
function asyncRetry<TFn>(fn, initialOptions?): (...args) => Promise<Awaited<ReturnType<TFn>> | undefined>;Defined in: async-retryer.ts:667
Creates a retry-enabled version of an async function. This is a convenience wrapper around the AsyncRetryer class that returns the execute method.
Type Parameters#
TFn#
TFn extends AnyAsyncFunction
Parameters#
fn#
TFn
The async function to add retry functionality to
initialOptions?#
AsyncRetryerOptions<TFn> = {}
Configuration options for the retry behavior
Returns#
A new function that executes the original with retry logic
(...args) => Promise<Awaited<ReturnType<TFn>> | undefined>
Example#
ts
// Define your async function normally
async function fetchData(url: string) {
const response = await fetch(url)
if (!response.ok) throw new Error('Request failed')
return response.json()
}
// Create retry-enabled function
const fetchWithRetry = asyncRetry(fetchData, {
maxAttempts: 3,
backoff: 'exponential',
baseWait: 1000,
jitter: 0.1
})
// Call it multiple times
const data1 = await fetchWithRetry('/api/data1')
const data2 = await fetchWithRetry('/api/data2')