Debouncer API Reference
- DebouncerOptions
- DebouncerState
- AsyncDebouncerOptions
- AsyncDebouncerState
- debounce
- asyncDebounce
- Debouncer
- AsyncDebouncer
- useAsyncDebouncedCallback
- useAsyncDebouncer
- useDebouncedCallback
- useDebouncedState
- useDebouncedValue
- useDebouncer
- OctaneAsyncDebouncer
- OctaneAsyncDebouncerOptions
- OctaneDebouncer
- OctaneDebouncerOptions
Throttler API Reference
- ThrottlerOptions
- ThrottlerState
- AsyncThrottlerOptions
- AsyncThrottlerState
- throttle
- asyncThrottle
- Throttler
- AsyncThrottler
- useAsyncThrottledCallback
- useAsyncThrottler
- useThrottledCallback
- useThrottledState
- useThrottledValue
- useThrottler
- OctaneAsyncThrottler
- OctaneAsyncThrottlerOptions
- OctaneThrottler
- OctaneThrottlerOptions
Rate Limiter API Reference
- RateLimiterOptions
- RateLimiterState
- AsyncRateLimiterOptions
- AsyncRateLimiterState
- rateLimit
- asyncRateLimit
- RateLimiter
- AsyncRateLimiter
- useAsyncRateLimitedCallback
- useAsyncRateLimiter
- useRateLimitedCallback
- useRateLimitedState
- useRateLimitedValue
- useRateLimiter
- OctaneAsyncRateLimiter
- OctaneAsyncRateLimiterOptions
- OctaneRateLimiter
- OctaneRateLimiterOptions
Queue API Reference
useRateLimitedCallback
function useRateLimitedCallback<TFn>(fn, options): (...args) => boolean;Defined in: rate-limiter/useRateLimitedCallback.ts:37
Returns a stable rate-limited callback owned by the Octane lifecycle.
Accepts updates while the configured limit has capacity in its fixed or sliding window. Rejected updates are discarded instead of delayed.
Return value#
Returns the bound maybeExecute method with the wrapped function's parameter types. It returns an accepted-or-rejected boolean.
State and ownership#
Use useRateLimiter when you need selected state or control methods. This callback does not expose the utility, its store, or a child subscription.
Call during component rendering. The hook retains its utility across renders and runs cleanup when the component unmounts. Options accept an object with top-level getters or an options factory. Function-valued core options remain callbacks. Local options override provider defaults without replacing the utility or its pending work. onUnmount replaces default cleanup and receives the utility instance. A custom callback must perform every needed cancel, stop, or abort action.
Type Parameters#
TFn#
TFn extends AnyFunction
Parameters#
fn#
TFn
options#
OctanePacerOptions<OctaneRateLimiterOptions<TFn, { }>>
Returns#
(...args): boolean;Attempts to execute the rate-limited function if within the configured limits. Will reject execution if the number of calls in the current window exceeds the limit.
Parameters#
args#
...Parameters<TFn>
Returns#
boolean
Example#
const rateLimiter = new RateLimiter(fn, { limit: 5, window: 1000 });
// First 5 calls will return true
rateLimiter.maybeExecute('arg1', 'arg2'); // true
// Additional calls within the window will return false
rateLimiter.maybeExecute('arg1', 'arg2'); // falseExample#
import { useRateLimitedCallback } from '@tanstack/octane-pacer'
// During component rendering:
const schedule = useRateLimitedCallback((value: number) => { console.log(value) }, { limit: 3, window: 1000 })
schedule(1)See#
useRateLimiter