The throttling pattern looks like the debouncing one,
but instead of restarting a timer when the machine receives an event,
it stops listening to events temporarily.
In the following example, when the machine receives the first click event,
it goes into the Throttling state. The click event is not listened by the machine in this state.
The Throttling state starts a timer of one second, which targets the Idle state.
Example
Try incrementing the counter by clicking the Increment button below.
The counter will be incremented once every second.
The state machine is resilient to spamming. It controls how it should behave if the user abuses the button.
Count: 0
Throttling
Inspect the demo in Stately Inspector
Code
Get news from XState by Example
Sign up for the newsletter to be notified when more machines or an
interactive tutorial are released. I respect your privacy and will
only send emails once in a while.