-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add maxWait
option
#12
Conversation
index.d.ts
Outdated
@@ -7,6 +7,15 @@ declare namespace debounceFn { | |||
*/ | |||
readonly wait?: number; | |||
|
|||
/** | |||
Maximum time to wait until the `input` function is called. |
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.
It needs a clearer description of how it's different from wait
.
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.
It would also be useful to include a use-case for this option (like you mention in the PR description).
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.
You also need to update the readme.
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.
Also, make it clear that "time" is in milliseconds.
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.
I have tried to improve this. I'm not sure the first line is any better, but I don't how to make it better
It's still not clear to the user how |
Ive tried again to reword it based on what lodash say |
readme.md
Outdated
##### maxWait | ||
|
||
Type: `number`\ | ||
Default: `0` (disabled) |
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.
Readme and index.d.ts should be in sync.
Thanks :) |
This adds a
maxWait
option.The intention is to ensure that the callback is fired after at most maxWait of time.
This is particularly useful in the following situation. Perhaps this is streaming data of an volume control changing, but the source is sending updates too often.
wait=100, maxWait=1000
With the debounce being called every ~50ms for 30s.
Without this, only one update will be processed at the very end, rather than one every second.