I want a standard API for event throttling and debouncing #164
aarongustafson
started this conversation in
Wants
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There are numerous events in JavaScript that can get triggered repeatedly, necessitating that developers write additional code to throttle these events. For example:
change
event fires whenever a network change occurs, but this can happen in rapid succession when users pass through tunnels or move from WiFi to a cellular network. In almost all use cases, only the last event in the series is truly relevant.resize
event is fired repeatedly when a window corner is dragged to resize the browser application. In almost all cases, a developer who wants to know when a resize has occurred—so they can adjust the user experience in a responsive context—only cares about the final event.change
event on aninput
fires repeatedly when a user is typing, but for expensive operations like API lookups based on the entered content, developers will only want to trigger the API call when the user pauses for a bit or stops typing altogether.mousemove
event fires much faster than movement is perceivable by the human eye, so it would be useful to be able to throttle it to a lower frequency (e.g., 20 Hz).I want a native way to configure these (and similar) events to fire less frequently without having to write the debouncing and throttling code myself.
https://webwewant.fyi/wants/4/
Beta Was this translation helpful? Give feedback.
All reactions