2 ms·
I had no idea canceling a timeout like that was called debouncing.
by wnevets 12y ago
I had no idea canceling a timeout like that was called debouncing.
- angersock 12y agoIt goes back to something we used to do in electronics, usually with a Schmitt trigger. The idea was that even a good switch (say, a small contact switch or the like) would create several extra pulses as its internal contacts bounced against each other before settling when activated--hence the name: it removes bounces. :) Nowadays we can use _.debounce or _.throttle.
- jaredmcateer 12y agoNote throttle and debounce are slightly different. Debounce will delay firing until the event causing the timeout reset stops (or pre-fire on the first event and then ignore all subsequent events until they stop for a given interval,) where throttle will fire one event within a given interval no matter how many events it receives (as long as it's >=1.)
- vkjv 12y agoThe term debounce comes from the hardware world. When you press a physical button it's common place for the contact to bounce, causing the contact to open and close a few times in rapid succession. So you, debounce the button press to ensure that it only causes one edge or press to propagate to the rest of the circuit.