Episode 13 game · Raiden · Lightning
Raiden’s Throttle
Kai’s search box calls fetch on every keystroke, and his scroll progress bar runs on every scroll event. Feel the Storm of Requests, choose debounce or throttle for each handler, then prove that one word sends one request and the bar still moves while you scroll.
Search handler: search(e.target.value)
0 / 0 requests
1 · Feel the storm
Type Kai’s word into his search box, then scroll his page for two seconds. Watch the requests and the handler calls pile up.
2 · Tame each bolt
Pick the right tool for each handler. Wrong picks explain what goes wrong.
3 · The storm test
Kai’s code and yours face the same user: types “katana” with 120 ms between keys, then scrolls for two seconds (an event every 16 ms).
New seal earned
The Storm of Requests is spent
Acharya’s Rule #13Debounce until they stop. Throttle while they move.
The input event fires on every change, so calling fetch there sends one request per letter.
Each call restarts the timer. It runs once, about 300 ms after the user stops, with the latest value.
At most one call per interval while the user keeps going: right for scroll, drag and pointer moves.