Feature request: debounce decorator
See original GitHub issueSometimes you will want to limit triggers to a specific frequency. Therefore I would like to suggest a decorator that provides this functionality.
It would be similar to the existing @time_active decorator, only it would check the time elapsed since the last time a task was called. If that time exceeds a provided threshold, the task is called. Otherwise it is skipped.
Something like this:
@state_trigger('some condition')
@debounce(millis=300)
def some_task():
pass
Meaning that the task will only be exceuted if the last execution was more than 300ms ago.
I tried implementing this myself, only to find out that pyscript doesn’t support decorators.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
bvaughn/debounce-decorator
Debounce decorator. Debouncing is a JavaScript pattern commonly used for rate limiting event handlers for keyboard or scroll events.
Read more >3 Ways to Debounce HTTP Requests in Angular
3 Ways to Debounce HTTP Requests in Angular · 1. Using RxJS · 2. Using lodash/underscore debounce method · 3. Using decorators.
Read more >Debounce in JavaScript — A Fantastic Design Pattern to ...
Debounce is an awesome functionality to subtly guide desired user behaviour. It also prevents database corruption, as we saw above. Hope you ...
Read more >Simple Angular Debounce using RxJS
Optimize search UX by showing results as the user types, debouncing is used to avoid unnecessary server calls after every keystroke.
Read more >react-debounce-decorator - npm package
Learn more about react-debounce-decorator: package health score, ... up to date on security alerts and receive automatic fix pull requests.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Added
state_hold
to@state_trigger
andtask.wait_until()
1a7b665I’ll test these tomorrow. THANK YOU!