Here's an interesting one. I'm working with FRP, and looking at the 'debounce' methods in various libraries (jQuery, Bacon.js). I started working with this, and found it almost does what I need, but with a subtle difference. Here's my understanding of debounce as it relates to event handling:
When an event is happening with at least a certain frequency, don't do anything. Once the events slow down to less than the frequency, fire the event handler. For example (pseudo-code) for key-presses.debounce(1 second) then Alert
, we would see nothing happen if keys are pressed within a second of each other, until 1 second after the last key was pressed, then we'd get an Alert.
What I need is something that fires at the start of the sequence, not after the end. So, for the same example, we'd see the Alert immediately, then nothing. If the user starts pressing keys again after at least 1 second, we'd get another alert, then nothing again.
The code is easy - I just want a name for this. It still takes a single argument for the frequency: BeginSequence(1000)? AfterExpiry(1000)?
Any suggestions?