-
Notifications
You must be signed in to change notification settings - Fork 31
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
feat(throttle): add trailing
option
#127
feat(throttle): add trailing
option
#127
Conversation
falling
option for throttle
falling
option for throttle
falling
option for throttle
trailing
option for throttle
Corrected a few defects:
|
d4ba2f2
to
3be2da6
Compare
…ailing call, expand test
- Tweak some variable names - Make the “call time” variable always a number, so the undefined check can be removed - Inline all references to current time
3be2da6
to
251bffc
Compare
when invoked. When the returned function is invoked it will only call the source | ||
function if the `interval` milliseconds of time has passed. Otherwise, it will ignore | ||
the invocation. | ||
The `throttle` function creates a new function that, when called, will only execute the original function at most once per specified time interval. This is useful for limiting the rate at which a function can fire, especially for performance-intensive operations like handling scroll or resize events. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better!
trailing
option for throttle
trailing
option
Merging this with a failed test, which will be fixed in another PR. |
Thanks for the cleanup and refactoring! |
Thanks for contributing @crishoj. 👍 👍 Please keep up the great work :) I'll get to your other PR soon, but have some stuff to finish for the documentation site. |
Tip
The owner of this PR can publish a preview release by commenting
/publish
in this PR. Afterwards, anyone can try it out by runningpnpm add radashi@pr<PR_NUMBER>
.Summary
This adds a
trailing
option forthrottle
, which results in the source function being invoked again afterinterval
in case any calls were ignored during the throttled period.This is useful for situations where an observable is frequently changing, and we wish to throttle an observer without missing any updates.
Related issue, if any:
sodiray/radash#387
For any code change,
Does this PR introduce a breaking change?
No