BuildMidFrontendAuto-graded
Fix debounce and throttle that mistime event bursts
Both helpers fire on every call. Make debounce wait for a pause and throttle fire at most once per interval.Both utilities inrate_control.py currently run fn on every call. Change Debouncer so it waits until calls stop for wait seconds, then fires once with the last call's arguments, as a search box would. Throttler should fire on the first call and hold back the rest until interval has passed, as a scroll handler would. Read time only through the injected now clock and let the caller drive tick().30 min
python
You're done when
- A rapid burst of debounced calls fires once, with the last call's arguments.
- The debounced call doesn't fire until the full quiet period has passed.
- A new call during the wait pushes the deadline back.
- A second burst, after the first one has fired, fires once more.
- Flushing the debouncer fires the waiting call straight away, and only once.
- The throttled call runs immediately on the first call, with its arguments, and only once per interval.
- Further calls inside that interval are held back.
- The held-back calls come out as one trailing call, with the last arguments, once the interval has passed.
- Flushing the throttle fires the held-back call straight away, and only once.
What it measures
Event-driven designWhether each utility lets the right calls through to the expensive work, on the right edge.
State across callsHow pending calls, deadlines and arguments are kept between calls without going stale.
Timing detailTelling the leading edge from the trailing edge, and knowing exactly when a deadline moves.
Your environment
Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards
Start this lab
30 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo