Skip to content

Feature request: debounce decorator #54

@phha

Description

@phha

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions