本页还没有译文
本页 12 段还没译成Русский,下面显示的是英文原文。throttleStrategy
还没翻译译自英文(tanstack.com)本页 12 段都还没译
function throttleStrategy(options): ThrottleStrategy;Defined in: packages/db/src/strategies/throttleStrategy.ts:49
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
Returns
A throttle strategy instance
Examples
// 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 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
})
})AI 翻译查看英文原文