question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: debounce decorator

See original GitHub issue

Sometimes 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:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
craigbarrattcommented, Oct 25, 2020

Added state_hold to @state_trigger and task.wait_until() 1a7b665

0reactions
dlashuacommented, Oct 26, 2020

I’ll test these tomorrow. THANK YOU!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found