Skip to content

docs(refDebounce,refThrottled): add usage example with object ref #4898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 22, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
docs(refThrottled): update
  • Loading branch information
ilyaliao committed Jul 21, 2025
commit dc4d7c284e6a73ba543dac94cdb26b91a9a0ba07
21 changes: 11 additions & 10 deletions packages/shared/refThrottled/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,24 @@ import { refThrottled } from '@vueuse/core'
import { shallowRef } from 'vue'

const data = shallowRef({
count: 0,
name: 'foo',
age: 18,
})
const throttled = refThrottled(data, 1000)

function update() {
data.value = {
...data.value,
name: 'bar',
}
}
data.value = { count: 1, name: 'foo' }
console.log(throttled.value) // { count: 1, name: 'foo' } (immediate)

console.log(throttled.value) // { name: 'foo', age: 18 }
data.value = { count: 2, name: 'bar' }
data.value = { count: 3, name: 'baz' }
data.value = { count: 4, name: 'qux' }
console.log(throttled.value) // { count: 1, name: 'foo' } (still first value)

// After 1000ms, next change will be applied
await sleep(1100)

console.log(throttled.value) // { name: 'bar', age: 18 }
data.value = { count: 5, name: 'final' }
await nextTick()
console.log(throttled.value) // { count: 5, name: 'final' } (updated)
```

### Trailing
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy