File: throttleStrategy.md | Updated: 11/15/2025
Search...
+ K
Auto
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide
Documentation
Framework
React
Version
Latest
Search...
+ K
Menu
Getting Started
Guides
Collections
Frameworks
Community
API Reference
Framework
React
Version
Latest
Menu
Getting Started
Guides
Collections
Frameworks
Community
API Reference
On this page
Copy Markdown
Function: throttleStrategy()
============================
ts
function throttleStrategy(options): ThrottleStrategy;
function throttleStrategy(options): ThrottleStrategy;
Defined in: packages/db/src/strategies/throttleStrategy.ts:48
Creates a throttle strategy that ensures transactions are evenly spaced over time.
Provides smooth, controlled execution patterns ideal for UI updates like sliders, progress bars, or scroll handlers where you want consistent execution timing.
Parameters
----------
### options
Configuration for throttle behavior
A throttle strategy instance
ts
// Throttle slider updates to every 200ms
const mutate = usePacedMutations({
onMutate: (volume) => {
settingsCollection.update('volume', draft => { draft.value = volume })
},
mutationFn: async ({ transaction }) => {
await api.updateVolume(transaction.mutations)
},
strategy: throttleStrategy({ wait: 200 })
})
// Throttle slider updates to every 200ms
const mutate = usePacedMutations({
onMutate: (volume) => {
settingsCollection.update('volume', draft => { draft.value = volume })
},
mutationFn: async ({ transaction }) => {
await api.updateVolume(transaction.mutations)
},
strategy: throttleStrategy({ wait: 200 })
})
ts
// Throttle with leading and trailing execution
const mutate = usePacedMutations({
onMutate: (data) => {
collection.update(id, draft => { Object.assign(draft, data) })
},
mutationFn: async ({ transaction }) => {
await api.save(transaction.mutations)
},
strategy: throttleStrategy({
wait: 500,
leading: true,
trailing: true
})
})
// Throttle with leading and trailing execution
const mutate = usePacedMutations({
onMutate: (data) => {
collection.update(id, draft => { Object.assign(draft, data) })
},
mutationFn: async ({ transaction }) => {
await api.save(transaction.mutations)
},
strategy: throttleStrategy({
wait: 500,
leading: true,
trailing: true
})
})
