Debouncer API Reference
- DebouncerOptions
- DebouncerState
- AsyncDebouncerOptions
- AsyncDebouncerState
- debounce
- asyncDebounce
- Debouncer
- AsyncDebouncer
- AsyncDebouncerController
- DebouncerController
- createAsyncDebouncer
- createDebouncedState
- createDebouncedValue
- createDebouncer
- LitAsyncDebouncer
- LitAsyncDebouncerOptions
- LitDebouncer
- LitDebouncerOptions
Throttler API Reference
- ThrottlerOptions
- ThrottlerState
- AsyncThrottlerOptions
- AsyncThrottlerState
- throttle
- asyncThrottle
- Throttler
- AsyncThrottler
- AsyncThrottlerController
- ThrottlerController
- createAsyncThrottler
- createThrottledState
- createThrottledValue
- createThrottler
- LitAsyncThrottler
- LitAsyncThrottlerOptions
- LitThrottler
- LitThrottlerOptions
Rate Limiter API Reference
- RateLimiterOptions
- RateLimiterState
- AsyncRateLimiterOptions
- AsyncRateLimiterState
- rateLimit
- asyncRateLimit
- RateLimiter
- AsyncRateLimiter
- AsyncRateLimiterController
- RateLimiterController
- createAsyncRateLimiter
- createRateLimitedState
- createRateLimitedValue
- createRateLimiter
- LitAsyncRateLimiter
- LitAsyncRateLimiterOptions
- LitRateLimiter
- LitRateLimiterOptions
Queue API Reference
createThrottledState
function createThrottledState<TValue, TSelected>(
host,
initialValue,
options,
selector?): [CellValue<TValue>, SetValue<TValue>, LitThrottler<SetValue<TValue>, TSelected>];Defined in: throttler/createThrottledState.ts:39
Creates throttled state with a scheduled setter.
Limits execution to the configured wait interval. Leading and trailing execution are enabled by default, and the latest blocked update is retained for the trailing edge.
Return value#
Returns [value, setValue, utility]. The value is an accessor; call value() from render(). Setters accept a value or a functional updater. Updaters run when the utility executes, using the last committed value. Pending updates may be replaced or rejected according to the utility's scheduling rules. To store a function itself, pass an updater that returns that function.
State and ownership#
The value updates independently of the utility selector. The default utility selection is {}. Pass a selector to subscribe to fields such as executionCount, isPending, or status where the underlying utility exposes them.
Pass the owning ReactiveControllerHost first. Host updates refresh options. Disconnecting runs cleanup; reconnecting restores subscriptions to the same utility. 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#
TValue#
TValue
TSelected#
TSelected = { }
Parameters#
host#
ReactiveControllerHost
initialValue#
TValue
options#
LitPacerOptions<LitThrottlerOptions<SetValue<TValue>, TSelected>>
selector?#
(state) => TSelected
Returns#
[CellValue<TValue>, SetValue<TValue>, LitThrottler<SetValue<TValue>, TSelected>]
Example#
import { createThrottledState } from '@tanstack/lit-pacer'
// In a LitElement constructor:
const [count, setCount, utility] = createThrottledState(this, 0, { wait: 500 },
(state) => ({ executionCount: state.executionCount }),
)
setCount((previous) => previous + 1)
// Bind count and utility.state in the component. Read count() for the committed value.See#
createThrottler