-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
Support arguments for rate-limited functions #316
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trungleduc
reviewed
Jul 20, 2022
trungleduc
reviewed
Jul 20, 2022
afshin
force-pushed
the
ratelimiter-arguments
branch
from
July 20, 2022 16:52
2ebd989
to
54fe387
Compare
afshin
changed the title
Support arguments to invoke a rate limited function with
Support arguments for rate-limited functions
Jul 20, 2022
…ing passed into the underlying function
afshin
force-pushed
the
ratelimiter-arguments
branch
3 times, most recently
from
July 21, 2022 02:41
02503bc
to
a0f194a
Compare
afshin
force-pushed
the
ratelimiter-arguments
branch
from
July 21, 2022 03:05
a0f194a
to
a9c2ce0
Compare
afshin
force-pushed
the
ratelimiter-arguments
branch
from
July 21, 2022 03:11
a9c2ce0
to
e1782ff
Compare
fcollonval
approved these changes
Jul 21, 2022
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.
Minor optional suggestion otherwise it looks good to me.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes
Debouncer#invoke
andThrottler#invoke
to support passing arguments into the underlying function being debounced or throttled.Problem
@trungleduc points out a debouncing use case that uses arguments, which is not possible with
Debouncer
and required writing adebounce
function:The
debounce
function allows for passing a debounced function passed viaprops
in a component:The debounced function is invoked via
props
:Solution
With this PR, a
Debouncer
instance supports arguments. It can be passed viaprops
:And it is invoked via
props
:Examples
This snippet will log
Hello, Louie
to the console.This snippet will log
Hello, Huey
to the console.This snippet will log
Hello, world
to the console.Backward-compatibility
This change is fully backward-compatible. However, sub-classes of
RateLimiter
should note that if they plan to useprotected args
they must setthis.args
inside theirinvoke
method.Semantic versioning
This PR changes the API in a backward-compatible way and adds a new feature. It is a minor version bump.