-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Recently I compared lodash's throttle
and useThrottleFn
. I found the leading
and trailing
options are different between them.
- Here is how both differs when we call the throttled function 3 times, without waiting, as call1, call2 and call3
Leading | Trailing | Lodash throttle | Vueuse useThrottleFn |
---|---|---|---|
True | True | call1 runs immediately. call3 runs after timeout | call1 runs immediately. call3 runs after timeout |
True | False | only call1 runs immediately | only call1 runs immediately |
False | True | only call3 runs after the timeout | call2 runs immediately, call3 runs after timeout |
False | False | nothing runs | only call2 runs immediately |
So if this isn't intended behavior, that shows there is a problem with leading false option. When leading is false, the second call of the throttled function immediately triggers it.
If you confirm this isn't intended behavior and a bug, I can create a PR with confirming test cases for it too.
This also might be related with #4551
Reproduction
https://stackblitz.com/edit/vueuse-lodash-throttle-compare?file=README.md
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 20.19.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@vueuse/core: ^13.5.0 => 13.5.0
Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a VueUse issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working